내 앱에 Miles Johnsons 우수한 업 로더 구성 요소를 구현하려고합니다. 그러나 여기에 문제가 있습니다 : 업로드 된 이미지의 크기에 따라 크기 변경 치수를 변경해야합니다. 내가 올바른 변환을 정확히 파악할 수 있어요,하지만 어떻게 이미지의 크기가 beforeTransform
의 내부 변형 될 액세스합니까CakePHP 업 로더 : 이미지 크기에 따라 크기 변경 값을 변경하십시오.
public $actsAs = array(
'Uploader.Attachment' => array(
'image' => array(
'nameCallback' => 'formatName',
'tempDir' => TMP,
'uploadDir' => UPLOADDIR,
'finalPath' => '/img/photos/',
'overwrite' => false,
'stopSave' => true,
'allowEmpty' => false,
'transforms' => array(
array(
'class' => 'exif',
'self' => true
),
'image_sized' => array(
'class' => 'resize',
'nameCallback' => 'transformSizedNameCallback',
'width' => 1680,
'height' => 980,
'aspect' => true
)
)
)
),
'Uploader.FileValidation' => array(
'image' => array(
'extension' => array(
'value' => array('jpg', 'png', 'jpeg'),
'error' => 'Nicht unterstütztes Dateiformat - bitte JPG- oder PNG-Datei hochladen.'
),
'minHeight' => array(
'value' => 980,
'error' => 'Das Bild muss mindestens 980 Pixel hoch sein.'
),
'minWidth' => array(
'value' => 980,
'error' => 'Das Bild muss mindestens 980 Pixel breit sein.'
),
'required' => array(
'value' => true,
'error' => 'Bitte wählen Sie ein Bild aus.'
)
)
)
);
public function beforeTransform($options) {
if($options['dbColumn'] == 'image_sized') {
if($height > $width) {
$options['width'] = 980;
$options['height'] = 1680;
}
}
return $options;
}
:
나는 콜백의 변환을 수정하려고? 어디에서$width
과
$height
을 얻을 수 있습니까?