Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use srcset instead of rewriting the src url. Ignore the dimensions #8

Open
brendanheywood opened this issue Dec 13, 2017 · 3 comments

Comments

@brendanheywood
Copy link
Collaborator

The rewritten img tag should ignore the dimensions in the tag, which also has the side benefit of allowing images with a % based width to be optimized.

Instead it should just add a scrset which points to all the optimized sizes. In conjunction with #7 is should detect when an image needs to be resized based on dimensions and then queue up the asynchronous production of a set of better sizes, which could possibly be set in site config.

A good guide might be to resize anything over 200x200 pixels, and produce a set of sizes up to the largest reasonable desktop or retina size.

ie if an image comes in which is 2000x1800 you could say 'give me the largest image which fits in 1000x1000 as the first size, and then 640x640 and 320x320 which would produce these 3 sizes for the srcset:

  1. 1000 x 900
  2. 640 x 576
  3. 320 x 288

Or alternatively a better algorithm might instead of using x and y limits, use a pixel count limit for each size, eg the largest size should be no more than 1 megapixel, medium no more than .5 megapixels and small .2 megapixels.

@gthomas2
Copy link
Owner

Hi Branden, thanks for raising this issue and #7. I'm wiped out after watching Star Wars until 3:30am so I'll have to look at this next week. Sounds like you have some great ideas for making the filter better (and more secure) and I'll look at them in detail as soon as I can. Feel free to file a pull request if you get time.

@azrek
Copy link

azrek commented May 9, 2018

hi gthomas2,

Have you made any progress in this issue?

Thanks,
Ghada

@ilyatregubov
Copy link

HI @gthomas2 is there any progress on this?
Thanks,
Ilya

jay-oswald pushed a commit to jay-oswald/moodle-filter_imageopt that referenced this issue Feb 23, 2024
Refactor to use core file_storage->convert_image()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants