diff options
author | Robert Speicher <rspeicher@gmail.com> | 2017-09-12 11:14:54 -0400 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2017-09-12 11:54:14 -0400 |
commit | 6a97759ea86cd6d15eea1b17fd2526b4f0569108 (patch) | |
tree | 74d3ff854e59bc400a70bf3783bcfdf51f2e9e48 | |
parent | 0cd1563fb66e9ba533346fe3957912225e27000f (diff) | |
download | gitlab-ce-6a97759ea86cd6d15eea1b17fd2526b4f0569108.tar.gz |
Remove ImageLazyLoadFilter from EmailPipeline37629-lazy-image-loading-breaks-notification-mails-for-an-added-screenshot
4 files changed, 27 insertions, 1 deletions
diff --git a/changelogs/unreleased/37629-lazy-image-loading-breaks-notification-mails-for-an-added-screenshot.yml b/changelogs/unreleased/37629-lazy-image-loading-breaks-notification-mails-for-an-added-screenshot.yml new file mode 100644 index 00000000000..5735d59a2bd --- /dev/null +++ b/changelogs/unreleased/37629-lazy-image-loading-breaks-notification-mails-for-an-added-screenshot.yml @@ -0,0 +1,5 @@ +--- +title: Image attachments are properly displayed in notification emails again +merge_request: 14161 +author: +type: fixed diff --git a/lib/banzai/filter/image_lazy_load_filter.rb b/lib/banzai/filter/image_lazy_load_filter.rb index bcb4f332267..4cd9b02b76c 100644 --- a/lib/banzai/filter/image_lazy_load_filter.rb +++ b/lib/banzai/filter/image_lazy_load_filter.rb @@ -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| diff --git a/lib/banzai/pipeline/email_pipeline.rb b/lib/banzai/pipeline/email_pipeline.rb index e47c384afc1..8f5f144d582 100644 --- a/lib/banzai/pipeline/email_pipeline.rb +++ b/lib/banzai/pipeline/email_pipeline.rb @@ -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 diff --git a/spec/lib/banzai/pipeline/email_pipeline_spec.rb b/spec/lib/banzai/pipeline/email_pipeline_spec.rb new file mode 100644 index 00000000000..6a11ca2f9d5 --- /dev/null +++ b/spec/lib/banzai/pipeline/email_pipeline_spec.rb @@ -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 |