How do you get the thumbnail not the feature image from the posts query using WPGraphQL Headless?
I can see that you can quite easily get the featured image and then it has srcSets for different imagery of a smaller size but there is no option that is clear that would give me the posts thumbnail image.
The reason I want to get a thumbnail instead of a featured image is because of performance.
2
Answers
Just had the very same question and hacked it with a one-liner that returns the thumbnail URL from the image’s original sourceUrl:
Since it adds a fixed string for the size variant it only works for fixed/cropped image sizes such as thumbnail.
if it can help someone, my srcset is empty in the GQL answer so it doesn’t work as expected.
I get the wp thumbnails using "mediaDetails" like so :