7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/redmineup/liquid/filters/additional.rb', line 7
def parse_inline_attachments(text, obj)
attachments = obj.attachments if obj.respond_to?(:attachments)
if attachments.present?
text.gsub!(/src="([^\/"]+\.(bmp|gif|jpg|jpe|jpeg|png))"(\s+alt="([^"]*)")?/i) do |m|
filename, ext, alt, alttext = $1, $2, $3, $4
if found = Attachment.latest_attach(attachments, CGI.unescape(filename))
image_url = found.url
desc = found.description.to_s.delete('"')
if !desc.blank? && alttext.blank?
alt = " title=\"#{desc}\" alt=\"#{desc}\""
end
"src=\"#{image_url}\"#{alt} loading=\"lazy\""
else
m
end
end
end
text
end
|