FIX: Copying image markdown for secure media loading full image (#9488)

* When copying the markdown for an image between posts, we were not adding the srcset and data-small-image attributes which are done by calling optimize_image! in cooked post processor
* Refactored the code which was confusing in its current state (the consider_for_reuse method was super confusing) and fixed the issue
This commit is contained in:
Martin Brennan
2020-04-24 10:29:02 +10:00
committed by GitHub
parent bd3425b389
commit cd1c7d7560
3 changed files with 15 additions and 54 deletions

View File

@ -339,12 +339,7 @@ class CookedPostProcessor
width, height = ImageSizer.resize(width, height)
end
# if the upload already exists and is attached to a different post,
# or the original_sha1 is missing meaning it was created before secure
# media was enabled. we want to re-thumbnail and re-optimize in this case
# to avoid using uploads linked to many other posts
upload = Upload.consider_for_reuse(Upload.get_from_url(src), @post)
upload = Upload.get_from_url(src)
if upload.present?
upload.create_thumbnail!(width, height, crop: crop)