diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-05-19 10:33:21 +0300 |
commit | 36a59d088eca61b834191dacea009677a96c052f (patch) | |
tree | e4f33972dab5d8ef79e3944a9f403035fceea43f /lib/banzai/filter | |
parent | a1761f15ec2cae7c7f7bbda39a75494add0dfd6f (diff) |
Add latest changes from gitlab-org/gitlab@15-0-stable-eev15.0.0-rc42
Diffstat (limited to 'lib/banzai/filter')
-rw-r--r-- | lib/banzai/filter/image_lazy_load_filter.rb | 4 | ||||
-rw-r--r-- | lib/banzai/filter/references/abstract_reference_filter.rb | 5 | ||||
-rw-r--r-- | lib/banzai/filter/references/issue_reference_filter.rb | 4 |
3 files changed, 12 insertions, 1 deletions
diff --git a/lib/banzai/filter/image_lazy_load_filter.rb b/lib/banzai/filter/image_lazy_load_filter.rb index 916c135b777..a8a275d2039 100644 --- a/lib/banzai/filter/image_lazy_load_filter.rb +++ b/lib/banzai/filter/image_lazy_load_filter.rb @@ -4,13 +4,15 @@ module Banzai module Filter # HTML filter that moves the value of image `src` attributes to `data-src` - # so they can be lazy loaded. + # so they can be lazy loaded. Also sets decoding to 'async' so that the + # decoding of images doesn't block the loading of other content. class ImageLazyLoadFilter < HTML::Pipeline::Filter CSS = 'img' XPATH = Gitlab::Utils::Nokogiri.css_to_xpath(CSS).freeze def call doc.xpath(XPATH).each do |img| + img['decoding'] = 'async' img.add_class('lazy') img['data-src'] = img['src'] img['src'] = LazyImageTagHelper.placeholder_image diff --git a/lib/banzai/filter/references/abstract_reference_filter.rb b/lib/banzai/filter/references/abstract_reference_filter.rb index a34519799d5..521fd7bf4cc 100644 --- a/lib/banzai/filter/references/abstract_reference_filter.rb +++ b/lib/banzai/filter/references/abstract_reference_filter.rb @@ -206,6 +206,7 @@ module Banzai link_content: !!link_content, link_reference: link_reference) data_attributes[:reference_format] = matches[:format] if matches.names.include?("format") + data_attributes.merge!(additional_object_attributes(object)) data = data_attribute(data_attributes) @@ -294,6 +295,10 @@ module Banzai placeholder_data[Regexp.last_match(1).to_i] end end + + def additional_object_attributes(object) + {} + end end end end diff --git a/lib/banzai/filter/references/issue_reference_filter.rb b/lib/banzai/filter/references/issue_reference_filter.rb index 1053501de7b..337075b7ff8 100644 --- a/lib/banzai/filter/references/issue_reference_filter.rb +++ b/lib/banzai/filter/references/issue_reference_filter.rb @@ -31,6 +31,10 @@ module Banzai private + def additional_object_attributes(issue) + { issue_type: issue.issue_type } + end + def issue_path(issue, project) Gitlab::Routing.url_helpers.namespace_project_issue_path(namespace_id: project.namespace, project_id: project, id: issue.iid) end |