-
Notifications
You must be signed in to change notification settings - Fork 447
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
Add src-set to attachments #796
Comments
@drewbaker thanks for opening this issue! How do you envision this working and what do you feel the expected output should be? So, it looks like there are a few variations of inputs for that function, such as I think we can support the |
It looks like that function outputs a list of URLs. So a query like:
Could return
Is that the shape you would expect? or something else? |
I can also see querying like so:
and getting (large as the first item)
|
I was thinking it would work like the first example, I don't think you need to request a specific size for
And the output you have. I'm not sure it needs to be an array, it seems like you'd only use it as a string to make an I'm not sure what that meta arg is for to be honest, I've only ever used this through the Check the source for that: It seems there are two attributes to get
And the return is a string for each? Just if you are curious, this is what a proper responsive image looks like:
|
@drewbaker so, In looking at WP Core, I only see https://github.com/WordPress/WordPress/search?l=PHP&q=wp_get_attachment_image_srcset Is there another function that's similar but more widely used? 🤔 |
Did you check this out? That |
ah ha! |
- Add assertion for srcSet field
#796 - Add srcSet field to media items
WordPress is great at generating the
src-set
for responsive images. It would be great if we could query an attachment forsrcSet
and get back the string that WordPress generates. It's tedious to build that on the frontend, and would require a large GQL, and also for the frontend to know what image sizes were available on the server.This is the function that WordPress has, where it takes an attachment ID and generates the
src-set
string for you:https://developer.wordpress.org/reference/functions/wp_get_attachment_image_srcset/
If you arn't using responsive images, you should! This is a good read:
https://alexwright.net/web-design-secrets/responsive-images-wordpress/
The text was updated successfully, but these errors were encountered: