Facebook Bot does not understand webp optimized images, yet.

23 views
Skip to first unread message

Matthieu-P. Schapranow

unread,
Jan 18, 2018, 3:40:29 AM1/18/18
to mod-pagespeed-discuss
Issue
When sharing a post on facebook including a link to a website serving optimized content by mod_pagespeed you might experience issue including a proper website preview / featured image. Investigating the issue using the FB developer tools might result in invalid image format or similar error message although you can view the corresponding image.

Reason
Apparently the facebook bot responsible for crawling and creating an adequate website preview does not understand the optimized image format delivered by mod_pagespeed.

Workaround
I believe FB developers are working on extending the facebook bot to support webp in future. In the meantime, you can prevent mod_pagespeed to optimize images for the facebook bot by including the following code snippet (compatible with Apache 2.4) to your apache config / .htaccess. It checks for the user agent facebookexternalhit and disables selected image conversion filters of mod_pagespeed.

  <IfModule pagespeed_module>
   
<If "%{HTTP_USER_AGENT} =~ /facebookexternalhit.*/">
      ModPagespeedDisableFilters convert_jpeg_to_webp,convert_png_to_jpeg
   
</If>
 
</IfModule>

Hope this helps,

Matthieu

هدوء مشاعر المملكة العربية السعودية

unread,
Jan 28, 2018, 9:03:32 PM1/28/18
to mod-pagespeed-discuss
Reply all
Reply to author
Forward
0 new messages