summaryrefslogtreecommitdiff
path: root/lib/banzai/filter/image_link_filter.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/banzai/filter/image_link_filter.rb')
-rw-r--r--lib/banzai/filter/image_link_filter.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/banzai/filter/image_link_filter.rb b/lib/banzai/filter/image_link_filter.rb
index ccd106860bd..f0fb6084a35 100644
--- a/lib/banzai/filter/image_link_filter.rb
+++ b/lib/banzai/filter/image_link_filter.rb
@@ -8,6 +8,10 @@ module Banzai
# of the anchor, and then replace the img with the link-wrapped version.
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',
@@ -17,7 +21,10 @@ module Banzai
)
link.children = img.clone
- img.replace(link)
+
+ div.children = link
+
+ img.replace(div)
end
doc