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

[5.x]: GraphQL product image format WebP not working #15572

Closed
MatthiasBrodelet opened this issue Aug 20, 2024 · 2 comments
Closed

[5.x]: GraphQL product image format WebP not working #15572

MatthiasBrodelet opened this issue Aug 20, 2024 · 2 comments
Assignees

Comments

@MatthiasBrodelet
Copy link

MatthiasBrodelet commented Aug 20, 2024

What happened?

Description

I'm not 100% if this issue should be posted here or in the CMS repository. Feel free to move it.

I am trying to fetch the product images with GraphQL using an image transform where I need each image in the original format and the WebP format.
Since I have 2 product types I guess I need to define this twice.

{
  products {
    id
    title
    slug
    url
    defaultPriceAsCurrency
    ... on coinsAndGoldBars_Product {
      images {
        url: url @transform (transform: "productThumbnail")
        webpUrl: url @transform (transform: "productThumbnail", format: "webp")
      }
    }
    ... on otherProducts_Product {
      images {
        url: url @transform (transform: "productThumbnail")
        webpUrl: url @transform (transform: "productThumbnail", format: "webp")
      }
    }
    variants {
      id
      title
      sku
      price
      stock
    }
  }
}

The query does not fail and the transform works but the WebP format is not working.
It just gives the same URL as the normal non WebP URL.

It also seems to return a slightly different path than when I do this with twig.

GraphQL image URL => https://the-house.lndo.site/uploads/products/_productThumbnail/1_4oz-Krugerrand2-Medium.png
Twig image URL => https://the-house.lndo.site/uploads/products/_400x400_fit_center-center_none/1_4oz-Krugerrand2-Medium.png

The working Twig WebP transform also seems to add a product ID in the URL.

Steps to reproduce

  1. Use the query above

Expected behavior

It should return the path to the WebP version of this image.

Actual behavior

It just returns the original image format.

Craft CMS version

5.3.4

Craft Commerce version

5.0.16.2

PHP version

8.2

Operating system and version

No response

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Copy link

linear bot commented Aug 20, 2024

@brandonkelly
Copy link
Member

Craft 4.11.5 and 5.4.6 are out now with a fix for this, via #15580.

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

3 participants