Update upload URL for importers


(Jay Pfaffman) #1

Uploads now generate Markdown like:

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

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

    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

    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…


(Gerhard Schlager) #2

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

upload.short_url || upload.url should work :wink:


(Gerhard Schlager) #3