summaryrefslogtreecommitdiffstats
path: root/app/helpers/application_helper.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2017-01-30 19:37:38 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2017-01-30 19:37:38 +0000
commit65804c34f3d19791b77df01898e6af18048c06d9 (patch)
treea43a2f921a6e6ad325ea7843ea4214a964db5556 /app/helpers/application_helper.rb
parentdf4564bbd429972f3c273852481f0fe43e1094c1 (diff)
downloadredmine-65804c34f3d19791b77df01898e6af18048c06d9.tar.gz
redmine-65804c34f3d19791b77df01898e6af18048c06d9.zip
Add support for @2x, @3x, etc. hires images (#24922).
Patch by Jan Schulz-Hofen. git-svn-id: http://svn.redmine.org/redmine/trunk@16311 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers/application_helper.rb')
-rw-r--r--app/helpers/application_helper.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index d1f359fbc..ced854693 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -636,7 +636,7 @@ module ApplicationHelper
parse_sections(text, project, obj, attr, only_path, options)
text = parse_non_pre_blocks(text, obj, macros) do |text|
- [:parse_inline_attachments, :parse_wiki_links, :parse_redmine_links].each do |method_name|
+ [:parse_inline_attachments, :parse_hires_images, :parse_wiki_links, :parse_redmine_links].each do |method_name|
send method_name, text, project, obj, attr, only_path, options
end
end
@@ -681,6 +681,15 @@ module ApplicationHelper
parsed
end
+ # add srcset attribute to img tags if filename includes @2x, @3x, etc.
+ # to support hires displays
+ def parse_hires_images(text, project, obj, attr, only_path, options)
+ text.gsub!(/src="([^"]+@(\dx)\.(bmp|gif|jpg|jpe|jpeg|png))"/i) do |m|
+ filename, dpr = $1, $2
+ m + " srcset=\"#{filename} #{dpr}\""
+ end
+ end
+
def parse_inline_attachments(text, project, obj, attr, only_path, options)
return if options[:inline_attachments] == false