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

responsive-image handling adds entries to srcset even if the source image is smaller #53

Open
jan-23 opened this issue Jul 30, 2021 · 0 comments

Comments

@jan-23
Copy link

jan-23 commented Jul 30, 2021

I have a set of images and some are large some are small.

My setup looks like this:

    'large': {
        'type': 'responsive-image',
        'srcset': [
            ('1000w', ["scale_out 1000 1 False"]),
            ('2000w', ["scale_out 2000 1 False"]),
            ('3000w', ["scale_out 3000 1 False"])
        ],
        'default': '1000w',
    },

I want 3 image sizes and no upscaling.

If the input image img_a.jpg is 3500px wide. I get a perfect srcset of:

<img 
   class="image-process-large" src="/large/1000w/img_a.jpg" 
   srcset="/large/1000w/img_a.jpg 1000w, /large/2000w/img_a.jpg 2000w, /large/3000w/img_a.jpg 3000w"/>

Where /large/1000w/img_a.jpg is 1000px wide, /large/2000w/img_a.jpg is 2000px wide and /large/3000w/img_a.jpg is 3000px wide.

But if I have an image img_b.jpg that is 1500px wide. I get the same srcset:

<img 
   class="image-process-large" src="/large/1000w/img_b.jpg" 
   srcset="/large/1000w/img_b.jpg 1000w, /large/2000w/img_b.jpg 2000w, /large/3000w/img_b.jpg 3000w"/>

Where /large/1000w/img_b.jpg is 1000px wide, /large/2000w/img_b.jpg is 1500px wide and /large/3000w/img_b.jpg is also 1500px wide.

It would be better if

  • /large/2000w/img_b.jpg and /large/3000w/img_b.jpg are not generated since they are not adding any information
  • the original image is used as a fallback

I propose that the generated tag sould look like this:

<img 
   class="image-process-large" src="/large/1000w/img_b.jpg" 
   srcset="/large/1000w/img_b.jpg 1000w, /img_b.jpg"/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants