Created
June 7, 2023 16:08
-
-
Save Korveld/0dc77f7e142d45f7177c9062024f461c to your computer and use it in GitHub Desktop.
PHP detect WebP image support
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if (strpos( $_SERVER['HTTP_ACCEPT'], 'image/webp' ) !== false) { ?> | |
<section | |
class="section" | |
style="background-image:url(path-to-webp-image);" | |
> | |
<?php } else { ?> | |
<section | |
class="section" | |
style="background-image:url(path-to-fallback-image);" | |
> | |
<?php } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment