Skip to content

Commit

Permalink
Fixes missing usage of webp_auto_support for console command (#7358)
Browse files Browse the repository at this point in the history
* Fixes missing usage of webp_auto_support for console command

* Updates Thumbnail.php with webp_auto_support Config changes

* Update bundles/CoreBundle/Command/ThumbnailsImageCommand.php

Co-authored-by: Divesh Pahuja <divesh.pahuja@pimcore.com>

* Updates Frontend.php with webp_auto_support Config changes

* Use assets offset for system configuration & move out of loop

* Use offset for system config

* Use offset for system config

* Update models/Asset/Image/Thumbnail.php

Co-authored-by: Divesh Pahuja <divesh.pahuja@pimcore.com>
Co-authored-by: Bernhard Rusch <brusch@users.noreply.github.com>
  • Loading branch information
3 people committed Oct 23, 2020
1 parent 459d889 commit f80d71c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 4 additions & 1 deletion bundles/CoreBundle/Command/ThumbnailsImageCommand.php
Expand Up @@ -165,6 +165,9 @@ private function fetchThumbnailConfigs(InputInterface $input): array
*/
$thumbnailsToGenerate = [];

$config = \Pimcore\Config::getSystemConfiguration('assets');
$isWebPAutoSupport = $config['image']['thumbnails']['webp_auto_support'] ?? false;

foreach ($thumbnailConfigList as $thumbnailConfig) {
if (empty($allowedThumbs) || in_array($thumbnailConfig->getName(), $allowedThumbs)) {
$medias = array_merge(['default' => 'defaultMedia'], $thumbnailConfig->getMedias() ?: []);
Expand All @@ -188,7 +191,7 @@ private function fetchThumbnailConfigs(InputInterface $input): array
$resConfig->setHighResolution($resolution);
$thumbnailsToGenerate[] = $resConfig;

if (!$input->getOption('skip-webp') && $resConfig->getFormat() === 'SOURCE') {
if ($isWebPAutoSupport && !$input->getOption('skip-webp') && $resConfig->getFormat() === 'SOURCE') {
$webpConfig = clone $resConfig;
$webpConfig->setFormat('webp');
$thumbnailsToGenerate[] = $webpConfig;
Expand Down
5 changes: 3 additions & 2 deletions lib/Tool/Frontend.php
Expand Up @@ -150,8 +150,9 @@ public static function isOutputCacheEnabled()
*/
public static function hasWebpSupport()
{
$config = \Pimcore::getContainer()->getParameter('pimcore.config')['assets']['image']['thumbnails']['webp_auto_support'];
if ($config) {
$config = \Pimcore\Config::getSystemConfiguration('assets');
$isWebPAutoSupport = $config['image']['thumbnails']['webp_auto_support'] ?? false;
if ($isWebPAutoSupport) {
if (self::hasClientWebpSupport() && self::hasDocumentWebpSupport()) {
return true;
}
Expand Down
5 changes: 3 additions & 2 deletions models/Asset/Image/Thumbnail.php
Expand Up @@ -320,8 +320,9 @@ public function getHtml($options = [], $removeAttributes = [])
// $this->getConfig() can be empty, the original image is returned
if ($this->getConfig() && ($this->getConfig()->hasMedias() || $this->getConfig()->getForcePictureTag())) {
// output the <picture> - element
$isWebPAutoSupport = \Pimcore::getContainer()->getParameter('pimcore.config')['assets']['image']['thumbnails']['webp_auto_support'];
$isAutoFormat = (strtolower($this->getConfig()->getFormat()) === 'source' && $isWebPAutoSupport) ? true : false;
$config = \Pimcore\Config::getSystemConfiguration('assets');
$isWebPAutoSupport = $config['image']['thumbnails']['webp_auto_support'] ?? false;
$isAutoFormat = ($isWebPAutoSupport && strtolower($this->getConfig()->getFormat()) === 'source') ? true : false;
$webpSupportBackup = null;

if ($isAutoFormat) {
Expand Down

0 comments on commit f80d71c

Please sign in to comment.