WordPress / performance

Performance plugin from the WordPress Performance Group, which is a collection of standalone performance modules.
https://wordpress.org/plugins/performance-lab/
GNU General Public License v2.0
339 stars 91 forks source link

Investigate email client support for WebP, plugin usage #74

Closed adamsilverstein closed 2 years ago

adamsilverstein commented 2 years ago

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:

adamsilverstein commented 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?

adamsilverstein commented 2 years ago

Hey @dainemawer - are you still looking at this issue? Would love to hear your finding about WebP email support.

dainemawer commented 2 years ago

@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!

dainemawer commented 2 years ago

Hey @adamsilverstein I took a pretty detailed look into this ticket, here are my findings:

Screenshot 2022-02-09 at 08 46 27

WebP Support

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.

Src and Sizes Support

Screenshot 2022-02-09 at 08 55 20

The general support sentiment is this:

Can I Email reckons there is an overall support rate of 33.33%

Tests

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


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


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


adamsilverstein commented 2 years ago

@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.

dainemawer commented 2 years ago

@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:

  1. Some provides server email alternatives to that of wp_mail - for instance SendGrid
  2. Others like MailChimp for WordPress only really handles the tight-coupling through API's of subscription forms and lists.
  3. The odd one or two allow for building custom HTML newsletter templates from within the WP Dashboard. These plugins, for the most part rely on WP API's like wp_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:

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:

  1. Should we be supporting images by default in Core for RSS / Atom Feeds - in order to consider those who fire off RSS-To-Email features?
  2. It's kinda difficult to get stats on which email clients, subscribers of a list or RSS feed are using, so understanding support for WebP in that case could be greatly skewed compared to that of the greater internet.
  3. 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.

To me it seems like considering the variability, we should stick with JPEG in this regard.

adamsilverstein commented 2 years ago

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:

dainemawer commented 2 years ago

Makes sense @adamsilverstein - I'll take a stab at an approach tomorrow :)

dainemawer commented 2 years ago

@adamsilverstein - so based off of some further research, it sounds like there is a bit of work to do here:

WordPress Feeds

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.

Hooks / Filters

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" );

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!

bethanylang commented 2 years ago

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.

adamsilverstein commented 2 years ago

@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:

adamsilverstein commented 2 years ago

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.