Skip to content

Commit e0cf905

Browse files
committed
Include original canonical image src after rewriting
1 parent 2550387 commit e0cf905

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

lib/html/pipeline/camo_filter.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def call
3737
next if asset_hostname_whitelisted?(uri.hostname)
3838

3939
element['src'] = asset_proxy_url(uri.to_s)
40+
element['data-canonical-src'] = uri.to_s
4041
end
4142
doc
4243
end

test/html/pipeline/camo_filter_test.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ def test_camouflaging_http_image_urls
1717
orig = %(<p><img src="http://twitter.com/img.png"></p>)
1818
assert_includes 'img src="' + @asset_proxy_url,
1919
CamoFilter.call(orig, @options).to_s
20+
assert_includes 'data-canonical-src="http://twitter.com/img.png"',
21+
CamoFilter.call(orig, @options).to_s
2022
end
2123

2224
def test_doesnt_rewrite_dotcom_image_urls

0 commit comments

Comments
 (0)