spatie / statamic-responsive-images

Responsive images for Statamic 3
MIT License
99 stars 29 forks source link

Setting width to graphql does nothing #233

Closed SteJW closed 1 year ago

SteJW commented 1 year ago

Bug description

When I add a width to a GQL call, it basically does nothing. I still get all image sizes. When I need an of maximum 500px, it will still render everything with images of 1920px and more.

image {
        breakpoints {
          asset {
            id
            responsive(width: 450) {
              sources {
                srcSet
              }
            }
          }
        }

How to reproduce

Add an image, try the GQL call and you'll see it doesn't change anything.

Logs

No response

Environment

Statamic 4

Installation

Fresh statamic/statamic site via CLI

Antlers Parser

regex (default)

Additional details

When I change this:

Use glide_width

image {
        breakpoints {
          asset {
            id
            responsive(glide_width: 450) {
              sources {
                srcSet
              }
            }
          }
        }

In ResponsiveGraphqlArguments we should add this to the $defaultBreakpointArgs:


            'glide_width' => [
                'type' => Type::int(),
            ],

I didn't want to create a pull request for this, because there is no logic in doing it like this because of the glideArgs.

SteJW commented 1 year ago

Any ideas?

ncla commented 1 year ago

If glide_width parameter works then use that for now. But yeah this looks like a bug. Not much else I can say without looking at this in depth, don't have much time on me right now.

SteJW commented 1 year ago

Ok, thanks!

ncla commented 1 year ago

Hey, try out v4.1.0 - should be fixed.

SteJW commented 1 year ago

Yes, thank you! It worked perfectly.