Closed adamsilverstein closed 2 years ago
Question to investigate: how do email clients handle image markup when the img src references a jpeg (the original) and the srcset references WebP (the sub sizes), for example the markup in the description of https://github.com/WordPress/performance/issues/69?
Hey @dainemawer - are you still looking at this issue? Would love to hear your finding about WebP email support.
@adamsilverstein I am indeed! I have taken a look, I just need to compile my findings - I will most certainly update this ticket today if not tomorrow!
Hey @adamsilverstein I took a pretty detailed look into this ticket, here are my findings:
The general support sentiment is this:
Can I Email reckons overall there is a 85.30% support rate, with an additional 11.8% for partial support in the market. Pretty decent.
The general support sentiment is this:
Can I Email reckons there is an overall support rate of 33.33%
Anyway! I decided to test this out. As I cannot get debugging information from apps like Gmail or Mail on iOS. I opted to test in MacOS Mail on Desktop, the Gmail iOS App and Gmail in the browser. Here are my findings:
To start I tested the following markup:
<tbody>
<tr>
<td><img src="https://i.ibb.co/JvJCSHv/microsoft-365-y5y-Irf-ZXNHg-unsplash.webp" alt="Some WebP Image"></td>
</tr>
</tbody>
Results
.webp
image, no problem.webp
image too, assuming it converts the image to a jpeg
like the browser client.jpeg
Okay, so second test, lets try responsive images.
I tested with the following markup:
<tbody>
<tr>
<td><img src="https://i.ibb.co/GsxQ7CJ/microsoft-365-y5y-Irf-ZXNHg-unsplash.jpg" srcset="https://i.ibb.co/JvJCSHv/microsoft-365-y5y-Irf-ZXNHg-unsplash.webp 1024w" sizes="100vw" alt="Some WebP Image"></td>
</tr>
</tbody>
Results
srcset
and sizes
images - hard to tell which image was actually rendered. I can verify that the markup was not amended or changed by looking at the "Raw Source" of the image.srcset
and sizes
attribute and resolves to using the src
attribute value on a non-responsive image tag.I took one more stab at this to see if I could get some more accurate results
<tbody>
<tr>
<td><img src="https://i.ibb.co/GsxQ7CJ/microsoft-365-y5y-Irf-ZXNHg-unsplash.jpg" srcset="https://i.ibb.co/t2n84V0/art-320.webp 320w, https://i.ibb.co/W0bShWd/art-1024.webp 1024w" sizes="(min-width: 1024px) 50vw, 100vw" alt="Some WebP Image"></td>
</tr>
</tbody>
Results
@dainemawer Excellent, thanks for doing this research! We need to document this limitation in a dev note, so this issue will be a good reference.
A follow up item here would be to investigate existing email plugin integrations (eg MailChimp) to see where they pull their images from (RSS feed?). Then we could either automatically provide a jpeg there, or at least provide a way plugins can get one. I will create a follow up issue.
@adamsilverstein - so this has been leading me down a bit of a blurry rabbit hole. Based on some research I've basically identified 3 types of email plugins:
wp_mail
- for instance SendGridwp_get_attachment_image_src
- I think in this case we'd be okay if we're updating core functions?MailChimp does offer a service like: https://mailchimp.com/features/rss-to-email/ - however MailChimps Studio Editor doesn't support webp
- meaning two things:
webp
.webp
. Im assuming not if they only allow a small list of image formats to be uploaded by users.There are some plugins around like https://www.mailerlite.com/features/rss-to-email - which essentially makes featured images available in the RSS feed.
This leaves us in a bit of a strange position mainly because:
To me it seems like considering the variability, we should stick with JPEG in this regard.
Even so, I would think that this feature would need to account for either 2 separate RSS feeds (one .jpg, one .webp) as RSS feeds are consuming by many varying platforms from email to electron apps.
Thanks for the research here @dainemawer...
Good point, RSS feeds are also used as podcasting feeds, and podcast readers can display rich media including images, so again JPEG might be better to use here.
We should dig in a little more for the exact approach; I think we should:
Makes sense @adamsilverstein - I'll take a stab at an approach tomorrow :)
@adamsilverstein - so based off of some further research, it sounds like there is a bit of work to do here:
As we know, WP supports multiple feeds: RSS, RSS2, RDF and Atom. Im not entirely sure what the main differences are, but Im guessing if WP supports it in core, we should ensure the functionality remains intact.
There are a number of hooks and filters we can tap into: https://developer.wordpress.org/?s=rss&post_type%5B%5D=wp-parser-hook
Im not 100% sure as to why WP does not include featured images by default in feeds, but I wonder if this could be as simple as something like:
add_filter( "wp_feed_featured_images", "__return_true" );
feed
specific defaults - like image/jpeg
using is_feed
=> https://developer.wordpress.org/reference/functions/is_feed/ The other option, of course is to add a custom hook into the feed templates, something like do_action( "rss_featured_image" )
though Im not sure how much a feature like this deviates into Core as opposed to performance.
Maybe Im approaching this wrong, but its a start!
Removed Needs Dev and added Needs Discussion as it sounds like this issue is really just about the investigation of the approach for now. Once we decide on an approach, we can either change its title or close this one out and create a new issue for implementation.
@dainemawer I tested this with our current code approach which keeps jpeg images in the same meta/data locations they are currently generated, and adds WebP to output by rewriting the_content on the fly. In the default mode this means things like feeds continue to use the JPEG versions we also generate.
A few things to consider for this ticket going forward:
Thanks for the investigation on this ticket. No additional action is required here, so I'm going to close this out. Main takeaway is to ensure dev notes make email client limitations clear.
WordPress now supports WebP images, and this plugins
webp-uploads
module explores using WebP as the default sub size image format. During testing with WebP, one issue raised was support for the WebP format in email clients.Using WebP images in emails
According to Can I Email (at the time of this writing) support is very good, with >97% supporting either directly or by converting WebP images to JPEGs. However, one important exception is Outlook on Windows which does not support WebP.
Because WordPress sites can use their media library as the source of images when sending emails, for example newsletters - see https://wordpress.org/plugins/search/newsletters/ - we need to ensure we examine this issue.
Questions:
caniemail
suggests <3% so maybe sites can opt out if needed?