# 更新导入器的上传 URL

**URL:** <https://meta.discourse.org/t/update-upload-url-for-importers/87669>\
**Category:** Development\
**Created:** [2018年五月16日 18:16 UTC](https://meta.discourse.org/t/update-upload-url-for-importers/87669 "2018-05-16T18:16:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [2018年五月16日 18:16 UTC](https://meta.discourse.org/t/update-upload-url-for-importers/87669/1 "2018-05-16T18:16:33Z")

</div>

Uploads now generate Markdown like:

```
![square-abc-640|500x500](upload://md1vKocQHFmG9K4vpC57cKCTQv9.png)

```

`script/import_scripts/base/uploader.rb` does this:

```ruby
    def embedded_image_html(upload)
      image_width = [upload.width, SiteSetting.max_image_width].compact.min
      image_height = [upload.height, SiteSetting.max_image_height].compact.min
      %Q[<img src="#{upload.url}" width="#{image_width}" height="#{image_height}"><br/>]
    end

```

Should this be updated to use the new format? If so, should it call _whatever it is that generates the new format_ (and if so, where do I find that?) or just do it like

```ruby
    def embedded_image_html(upload)
      image_width = [upload.width, SiteSetting.max_image_width].compact.min
      image_height = [upload.height, SiteSetting.max_image_height].compact.min
      upload_name = upload.url.split('/').last
      %Q~![#{upload.original_filename}|#{image_width}x#{image_height}](#{upload_name})~
    end

```

Edit: well, that doesn’t quite work…

---

<div class="post-metadata">

**Author:** ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)\
**Post date:** [2018年五月16日 21:05 UTC](https://meta.discourse.org/t/update-upload-url-for-importers/87669/2 "2018-05-16T21:05:22Z")

</div>

> [@pfaffman](#):
>
> Should this be updated to use the new format?

Yes, I think it would be a good idea to have that available in Ruby as well. Currently it’s only available in JS.

[https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/lib/utilities.js.es6#L363-L364](https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/lib/utilities.js.es6#L363-L364)

> [@pfaffman](#):
>
> well, that doesn’t quite work…

`upload.short_url || upload.url` should work 😉

---

<div class="post-metadata">

**Author:** ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)\
**Post date:** [2018年六月17日 21:06 UTC](https://meta.discourse.org/t/update-upload-url-for-importers/87669/3 "2018-06-17T21:06:55Z")

</div>

[https://github.com/discourse/discourse/commit/3f167ae5ce71be706c72935e5c76718c14bc020d](https://github.com/discourse/discourse/commit/3f167ae5ce71be706c72935e5c76718c14bc020d)
