mirror of
https://github.com/discourse/discourse.git
synced 2025-08-20 18:52:44 +08:00
provide a way to give a default filename to pasted images in the lightbox overlay
This commit is contained in:
parent
a0031f2a0d
commit
72745d257d
17 changed files with 51 additions and 4 deletions
|
@ -141,19 +141,23 @@ class CookedPostProcessor
|
|||
meta["class"] = "meta"
|
||||
img.add_next_sibling meta
|
||||
|
||||
filename = upload ? upload.original_filename : File.basename(src)
|
||||
filename = get_filename(upload, src)
|
||||
informations = "#{original_width}x#{original_height}"
|
||||
informations << " | #{number_to_human_size(upload.filesize)}" if upload
|
||||
|
||||
meta.add_child create_span_node("filename", filename)
|
||||
meta.add_child create_span_node("informations", informations)
|
||||
meta.add_child create_span_node("expand")
|
||||
# TODO: download
|
||||
# TODO: views-count
|
||||
|
||||
@dirty = true
|
||||
end
|
||||
|
||||
def get_filename(upload, src)
|
||||
return File.basename(src) unless upload
|
||||
return upload.original_filename unless upload.original_filename == "blob"
|
||||
return I18n.t('upload.pasted_image_filename')
|
||||
end
|
||||
|
||||
def create_span_node(klass, content=nil)
|
||||
span = Nokogiri::XML::Node.new "span", @doc
|
||||
span.content = content if content
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue