summaryrefslogtreecommitdiff
path: root/lib/banzai
diff options
context:
space:
mode:
authorConnor Shea <connor.james.shea@gmail.com>2016-06-21 10:24:00 -0600
committerConnor Shea <connor.james.shea@gmail.com>2016-06-27 09:16:07 -0600
commitc7b04841c0b742146d88c63b83f6ac4474e77e05 (patch)
treea7ffe29f706a3acf0abf9a7070c51b660fed4b6b /lib/banzai
parentf48f7760c26e681e3f8b011c7c4e2b6ccfc9c3f5 (diff)
downloadgitlab-ce-c7b04841c0b742146d88c63b83f6ac4474e77e05.tar.gz
Wrap images in divs with Banzai and limit max-height.image-sizing
Add max-height to prevent images from displaying larger than the provided screen size. Also fix a failing test and add a new one.
Diffstat (limited to 'lib/banzai')
-rw-r--r--lib/banzai/filter/image_link_filter.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/banzai/filter/image_link_filter.rb b/lib/banzai/filter/image_link_filter.rb
index ccd106860bd..8aa6f8f124a 100644
--- a/lib/banzai/filter/image_link_filter.rb
+++ b/lib/banzai/filter/image_link_filter.rb
@@ -9,6 +9,11 @@ module Banzai
def call
doc.xpath('descendant-or-self::img[not(ancestor::a)]').each do |img|
+ div = doc.document.create_element(
+ 'div',
+ class: 'image-container'
+ )
+
link = doc.document.create_element(
'a',
class: 'no-attachment-icon',
@@ -17,7 +22,10 @@ module Banzai
)
link.children = img.clone
- img.replace(link)
+
+ div.children = link
+
+ img.replace(div)
end
doc