Merge branch '37629-lazy-image-loading-breaks-notification-mails-for-an-added-screenshot' into 'master'
Resolve "Lazy image loading breaks notification mails for an added screenshot" Closes #37629 See merge request !14161
This commit is contained in:
commit
9c9b1774cb
4 changed files with 27 additions and 1 deletions
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Image attachments are properly displayed in notification emails again
|
||||
merge_request: 14161
|
||||
author:
|
||||
type: fixed
|
|
@ -1,6 +1,7 @@
|
|||
module Banzai
|
||||
module Filter
|
||||
# HTML filter that moves the value of the src attribute to the data-src attribute so it can be lazy loaded
|
||||
# HTML filter that moves the value of image `src` attributes to `data-src`
|
||||
# so they can be lazy loaded.
|
||||
class ImageLazyLoadFilter < HTML::Pipeline::Filter
|
||||
def call
|
||||
doc.xpath('descendant-or-self::img').each do |img|
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
module Banzai
|
||||
module Pipeline
|
||||
class EmailPipeline < FullPipeline
|
||||
def self.filters
|
||||
super.tap do |filter_array|
|
||||
filter_array.delete(Banzai::Filter::ImageLazyLoadFilter)
|
||||
end
|
||||
end
|
||||
|
||||
def self.transform_context(context)
|
||||
super(context).merge(
|
||||
only_path: false
|
||||
|
|
14
spec/lib/banzai/pipeline/email_pipeline_spec.rb
Normal file
14
spec/lib/banzai/pipeline/email_pipeline_spec.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
require 'rails_helper'
|
||||
|
||||
describe Banzai::Pipeline::EmailPipeline do
|
||||
describe '.filters' do
|
||||
it 'returns the expected type' do
|
||||
expect(described_class.filters).to be_kind_of(Banzai::FilterArray)
|
||||
end
|
||||
|
||||
it 'excludes ImageLazyLoadFilter' do
|
||||
expect(described_class.filters).not_to be_empty
|
||||
expect(described_class.filters).not_to include(Banzai::Filter::ImageLazyLoadFilter)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue