Je dois dire que je ne l'ai pas testé ce morceau de code, je l'ai modifié pour un usage personnel et cela devrait aider votre problème.
Remplacer la culture de la fonction dans le plugin/téléchargeur/fournisseur/uploader.php
près de la ligne 368
avec la fonction suivante
public function crop(array $options = array(), $explicit = false) {
if ($this->_data[$this->_current]['group'] != 'image' || !$this->_enabled) {
return false;
}
$options = $options + array('location' => self::LOC_CENTER, 'quality' => 100, 'width' => null, 'height' => null, 'append' => null, 'prepend' => null);
$width = $this->_data[$this->_current]['width'];
$height = $this->_data[$this->_current]['height'];
$src_x = 0;
$src_y = 0;
$dest_w = $width;
$dest_h = $height;
$location = $options['location'];
if (is_numeric($options['width']) && is_numeric($options['height'])) {
$newWidth = $options['width'];
$newHeight = $options['height'];
if ($width/$newWidth > $height/$newHeight) {
$dest_h = $options['height'];
$dest_w = round($width/($height/$newHeight));
} else {
$dest_w = $options['width'];
$dest_h = round($height/($width/$newWidth));
}
} else {
if ($width > $height) {
$newWidth = $height;
$newHeight = $height;
} else {
$newWidth = $width;
$newHeight = $width;
}
$dest_h = $newHeight;
$dest_w = $newWidth;
}
$src_x = 0;
$src_y = 0;
if ($dest_w > $newWidth) {
$src_x = ceil((($dest_w - $newWidth)/2) * ($height/$newHeight));
}
if ($dest_h > $newHeight) {
$src_y = ceil((($dest_h - $newHeight)/2) * ($width/$newWidth));
}
$append = '_cropped_' . $newWidth . 'x' . $newHeight;
if ($options['append'] !== false && empty($options['append'])) {
$options['append'] = $append;
}
$transform = array(
'width' => $newWidth,
'height' => $newHeight,
'source_x' => $src_x,
'source_y' => $src_y,
'source_w' => $width,
'source_h' => $height,
'dest_w' => $dest_w,
'dest_h' => $dest_h,
'target' => $this->setDestination($this->_data[$this->_current]['name'], true, $options, false),
'quality' => $options['quality']
);
if ($this->transform($transform)) {
return $this->_returnData($transform, $append, $explicit);
}
return false;
}
Cordialement.
Voulez-vous dire 'resize' au lieu de 'crop'? –
redimensionner, recadrer ou redimensionner ET recadrer? – stillstanding
Je ne suis pas sûr de savoir comment le faire dans le bon sens. Je veux que l'image finale soit de la plus grande partie de l'image mais de la taille dont j'ai besoin. donc je pense qu'il peut être redimensionner et recadrer ou d'autres combinaisons. suis pas sûr. –