name given
                  
                  
                    return;
                  
                  
                  }
                  
                  
                  
                  
                  
                  $scriptProperties['debug'] = isset($debug) ? $debug : false;
                  
                  
                  
                  
                  
                  
                  
                  
                  static $pt_settings = array();
                  
                  
                  
                  
                  
                  if (empty($pt_settings)) {
                  
                  
                    if (!$modx->loadClass('phpThumbOf', MODX_CORE_PATH . 'components/phpthumbof/model/', true, true)) {
                  
                  
                      $modx->log(modX::LOG_LEVEL_ERROR, '[pThumb] Could not load phpThumbOf class.');
                  
                  
                      return $input;
                  
                  
                    }
                  
                  
                  }
                  
                  
                  
                  
                  
                  $pThumb = new phpThumbOf($modx, $pt_settings, $scriptProperties);
                  
                  
                  
                  
                  
                  $result = $pThumb->createThumbnail($input, $options);
                  
                  
                  
                  
                  
                  if (!empty($toPlaceholder) || $result['outputDims']) {
                  
                  
                    if ($result['width'] === '' && $result['file'] && $dims = getimagesize($result['file']) ) {
                  
                  
                        $result['width'] = $dims[0];
                  
                  
                        $result['height'] = $dims[1];
                  
                  
                    }
                  
                  
                    if (!empty($toPlaceholder)) {
                  
                  
                      $modx->setPlaceholders(array(
                  
                  
                        $toPlaceholder => $result['src'],
                  
                  
                        "$toPlaceholder.width" => $result['width'],
                  
                  
                        "$toPlaceholder.height" => $result['height']
                  
                  
                      ));
                  
                  
                      $output = '';
                  
                  
                    }
                  
                  
                    if ($result['outputDims']) {
                  
                  
                      $output = "src=\"{$result['src']}\"" . ($result['width'] ? " width=\"{$result['width']}\" height=\"{$result['height']}\"" : '');
                  
                  
                    }
                  
                  
                  }
                  
                  
                  else {
                  
                  
                    $output = $result['src'];
                  
                  
                  }
                  
                  
                  
                  
                  
                  if ($debug && $result['success']) {  // if debugging is on and createThumbnail was successful, log the debug info
                  
                  
                    $pThumb->debugmsg(isset($pThumb->phpThumb->debugmessages) ? ':: Processed ::' : ":: Loaded from cache: {$result['src']}", true);
                  
                  
                      
                  
                  
                  }
                  
                  
                  
                  
                  
                  $fullPath = str_replace("//",'/',MODX_BASE_PATH.$output);
                  
                  
                  // вот мой кусок
                  
                  
                  if(!file_exists("$fullPath.webp")) {
                  
                  
                     exec("sudo cwebp $fullPath -o $fullPath.webp");  
                  
                  
                  }
                  
                  
                  return $output;
                  
                  
                
это pthumb cниппет
Ну типа такого: Рядом со строкой $result = $pThumb->createThumbnail($input, $options); добавь ещё одну, такую же, почти $options2 = $options; $options2['f']='webp';//тут надо правильно задать, соответственно структуре массива $result2 = $pThumb->createThumbnail($input, $options2); Только тебе надо вывести options и заменить там опцию f которая у тебя в значении jpg скорее всего, на webp
Обсуждают сегодня