-
Notifications
You must be signed in to change notification settings - Fork 799
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
Photon: srcset support for post thumbnails #2919
Comments
Related: #2804 , which we've been tackling to add Photon + srcset support. Confirmed that we're not playing nicely with Twenty Sixteen's post thumbnail. Not sure why yet :) |
Cool. I'm not a developer but I'd be more than happy to help out any way I can by testing. |
Thanks @ChrisBegley! Core thumbnail retrieval happens in Confirmed the general area by trying Notes for testing: Test on a single post page, not an archive, unless you also have Carousel deactivated. Of note, when we disable our filter, the srcset values are Photonized, just not the img src tag. |
This is actually a result of #2281. With the When Photon returns it, we return the URL, and, usually, false for both the width and height (see discussion on 2281 for the rationale). The functions that filter and insert the srcset into the image tag for the thumbnail, though, use those values. |
@ChrisBegley, we've merged a patch for this in our If you'd rather wait for a beta, we'll be releasing one within a day or two. Thanks in advance! |
No problem! I just tested it out. The srcset attributes are added to the post thumbnails now. However, it's not respecting the crops of the thumbnails. It's adding "?w" instead of "?resize" to the srcset Photon URLs. For example: This: Should be this: This is what I have in my functions.php file for the homepage thumbnails: add_image_size( 'home-panel', 408, 227, true ); |
@ChrisBegley Is that the primary src, the srcset(s), or all of them? |
@kraftbj it's only the srcsets that aren't respecting the thumbnail crops. The primary src is correct. Here's what it's outputting:
|
Well, that's good news... this specific issue is being resolved, but failing at https://github.com/Automattic/jetpack/blob/master/class.photon.php#L582 that was fixed previously :) Not sure if I'll be able to hit this today, but noting for @dereksmart and @zinigor that we'd need to checkout what is available to us via the core filter, probably, and set the args smarter than just using the (Noting that the other issue should probably be re-opened, but I'm okay tracking this here since we'll get it fixed in the next day or so anyhow. #2804 ) |
There was some discussion in #2885 about whether we should be grabbing the height as well through the 2nd param of the filter $size_array, and went against it b/c it "worked" with minimal intrusion. seems like we need them for custom image sizes. Let's try and add them in. |
of course as I was writing this @kraftbj wrote a patch <3 |
@ChrisBegley we've pushed another patch for height dimensions. Mind giving it another spin? |
@dereksmart everything looks good! One side note... When I just overwrote all of the files in the plugin folder, it was acting like Photon wasn't active. I had to deactivate Photon and reactivate Photon in order to see the changes here, but everything looks like it's working fine now. |
I'm a huge fan of Photon and I've been following the responsive images project for the 4.4 release. I just tested out the latest Photon changes in the Master build of Jetpack with WordPress 4.4-beta2-35426 and the latest version of TwentySixteen. I noticed a few problems, here's my test site:
http://super.techyourworld.com/4-4-responsive-images-test/
It doesn't look like Photon is working on the post thumbnails. With Photon disabled, the
scrset
andsizes
attributes are added as expected:<img src="http://super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_0331.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="Batman_1989_0331" srcset="http://super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_0331-300x202.jpg 300w, http://super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_0331-1600x1076.jpg 1600w, http://super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_0331-800x538.jpg 800w, http://super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_0331-355x239.jpg 355w, http://super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_0331-394x265.jpg 394w, http://super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_0331-480x323.jpg 480w, http://super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_0331-580x390.jpg 580w, http://super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_0331-600x403.jpg 600w, http://super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_0331-710x477.jpg 710w, http://super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_0331-760x511.jpg 760w, http://super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_0331-900x605.jpg 900w, http://super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_0331-960x645.jpg 960w, http://super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_0331-1065x716.jpg 1065w, http://super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_0331-1160x780.jpg 1160w, http://super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_0331-1182x795.jpg 1182w, http://super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_0331-1440x968.jpg 1440w, http://super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_0331-1520x1022.jpg 1520w" sizes="(max-width: 1200px) 100vw, 1200px" data-id="5459" height="807" width="1200">
But with Photon activated, it strips out the
srcset
andsizes
attributes:<img src="http://i1.wp.com/super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_0331.jpg?w=1200&quality=85&strip=info" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="Batman_1989_0331" data-id="5459">
This only appears to be happening on post thumbnails. The image I inserted into the actual post displays
srcset
andsizes
, even with Photon activated:<img src="http://i1.wp.com/super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_010.jpg?resize=840%2C1277&quality=85&strip=info" alt="~" class="aligncenter size-full wp-image-5460" srcset="http://i1.wp.com/super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_010.jpg?w=197&quality=85&strip=info 197w, http://i1.wp.com/super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_010.jpg?w=745&quality=85&strip=info 745w, http://i1.wp.com/super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_010.jpg?w=800&quality=85&strip=info 800w, http://i1.wp.com/super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_010.jpg?w=300&quality=85&strip=info 300w, http://i1.wp.com/super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_010.jpg?w=355&quality=85&strip=info 355w, http://i1.wp.com/super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_010.jpg?w=394&quality=85&strip=info 394w, http://i1.wp.com/super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_010.jpg?w=480&quality=85&strip=info 480w, http://i1.wp.com/super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_010.jpg?w=580&quality=85&strip=info 580w, http://i1.wp.com/super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_010.jpg?w=600&quality=85&strip=info 600w, http://i1.wp.com/super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_010.jpg?w=710&quality=85&strip=info 710w, http://i1.wp.com/super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_010.jpg?w=760&quality=85&strip=info 760w, http://i1.wp.com/super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_010.jpg?w=900&quality=85&strip=info 900w, http://i1.wp.com/super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_010.jpg?w=960&quality=85&strip=info 960w, http://i1.wp.com/super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_010.jpg?w=1065&quality=85&strip=info 1065w, http://i1.wp.com/super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_010.jpg?w=1160&quality=85&strip=info 1160w, http://i1.wp.com/super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_010.jpg?w=1182&quality=85&strip=info 1182w, http://i1.wp.com/super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_010.jpg?w=1440&quality=85&strip=info 1440w, http://i1.wp.com/super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_010.jpg?w=1520&quality=85&strip=info 1520w, http://i1.wp.com/super.techyourworld.com/wp-content/uploads/2015/10/Batman_1989_010.jpg?w=1600&quality=85&strip=info 1600w" sizes="(max-width: 1738px) 100vw, 1738px" height="912" width="600">
The text was updated successfully, but these errors were encountered: