alexplusde / media_manager_responsive

REDAXO-Addon mit nützlichen Methoden im Umgang mit dem Picture-Element, Responsive Bilder, SVG-Ausgabe, u.v.m.
MIT License
9 stars 2 forks source link

Browser-Header auswerten, überflüssige Formate weglassen #9

Open alxndr-w opened 2 years ago

alxndr-w commented 2 years ago

https://github.com/nucliweb/image-element#use-a-cdn-image-service

alxndr-w commented 1 year ago
        $possible_types = rex_server('HTTP_ACCEPT', 'string', '');
        $types = explode(',', $possible_types);
        if (in_array('image/avif', $types)) {
            $subject->setCachePath($subject->getCachePath() . 'avif-');
        } elseif (in_array('image/webp', $types)) {
            $subject->setCachePath($subject->getCachePath() . 'webp-');
        } else {
            $subject->setCachePath($subject->getCachePath() . 'jpg-');
        }

wie in https://github.com/AndiLeni/media_negotiator/blob/main/boot.php