- code review for image rotation;

This commit is contained in:
nikitasinelnikov
2020-07-31 00:51:45 +03:00
parent 45b12fcd69
commit 585870bb3d
4 changed files with 11 additions and 11 deletions
+3 -3
View File
@@ -776,10 +776,10 @@ if ( ! class_exists( 'um\admin\core\Admin_Settings' ) ) {
),
array(
'id' => 'image_fix_orientation',
'id' => 'image_orientation_by_exif',
'type' => 'checkbox',
'label' => __( 'Fix image orientation','ultimate-member' ),
'tooltip' => __( 'Rotate image to fix orientation by the camera Exif data.','ultimate-member'),
'label' => __( 'Change image orientation', 'ultimate-member' ),
'tooltip' => __( 'Rotate image to and use orientation by the camera EXIF data.', 'ultimate-member' ),
),
array(
'id' => 'image_compression',
+1 -1
View File
@@ -565,7 +565,7 @@ if ( ! class_exists( 'um\Config' ) ) {
'mail_from' => get_bloginfo('name'),
'mail_from_addr' => get_bloginfo('admin_email'),
'email_html' => 1,
'image_fix_orientation' => 1,
'image_orientation_by_exif' => 0,
'image_compression' => 60,
'image_max_width' => 1000,
'cover_min_width' => 1000,
+6 -6
View File
@@ -745,21 +745,21 @@ if ( ! class_exists( 'um\core\Files' ) ) {
* @return resource
*/
function fix_image_orientation( $rotate, $source ) {
if ( extension_loaded('exif') ){
if ( extension_loaded('exif') ) {
$exif = @exif_read_data( $source );
if (isset($exif['Orientation'])) {
switch ($exif['Orientation']) {
if ( isset( $exif['Orientation'] ) ) {
switch ( $exif['Orientation'] ) {
case 3:
$rotate = imagerotate($rotate, 180, 0);
$rotate = imagerotate( $rotate, 180, 0 );
break;
case 6:
$rotate = imagerotate($rotate, -90, 0);
$rotate = imagerotate( $rotate, -90, 0 );
break;
case 8:
$rotate = imagerotate($rotate, 90, 0);
$rotate = imagerotate( $rotate, 90, 0 );
break;
}
}
+1 -1
View File
@@ -1201,7 +1201,7 @@ if ( ! class_exists( 'um\core\Uploader' ) ) {
* @return array
*/
public function rotate_uploaded_image( $movefile ) {
$image_fix_orientation = UM()->options()->get( 'image_fix_orientation' );
$image_fix_orientation = UM()->options()->get( 'image_orientation_by_exif' );
if ( $image_fix_orientation && $movefile['type'] == 'image/jpeg' ) {
$image = imagecreatefromjpeg( $movefile['file'] );
if ( $image ) {