Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Zallmann <tzallmann@gitlab.com>2017-09-13 11:26:18 +0300
committerTim Zallmann <tzallmann@gitlab.com>2017-10-12 13:31:54 +0300
commit87a70045e45b5bdd6b0cbe7b6aa7db93a457b948 (patch)
tree339c970af4dbe0692cdac5016c5fa0c8e6b7d207 /lib/banzai/filter/image_lazy_load_filter.rb
parent1e4b75ba40570a3e96e1999e375a120c4ba8b346 (diff)
Saving the Image Size to the URL and then Interpret it in the Lazy Load Filter for actual dimensions
Diffstat (limited to 'lib/banzai/filter/image_lazy_load_filter.rb')
-rw-r--r--lib/banzai/filter/image_lazy_load_filter.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/banzai/filter/image_lazy_load_filter.rb b/lib/banzai/filter/image_lazy_load_filter.rb
index 4cd9b02b76c..86d14db0ba0 100644
--- a/lib/banzai/filter/image_lazy_load_filter.rb
+++ b/lib/banzai/filter/image_lazy_load_filter.rb
@@ -7,6 +7,12 @@ module Banzai
doc.xpath('descendant-or-self::img').each do |img|
img['class'] ||= '' << 'lazy'
img['data-src'] = img['src']
+ if img['src'].include?('?wi=')
+ uri = URI.parse(img['src'])
+ sizeParameters = URI.decode_www_form(uri.query).to_h
+ img['width'] = sizeParameters['wi']
+ img['height'] = sizeParameters['he']
+ end
img['src'] = LazyImageTagHelper.placeholder_image
end