BuddyDev

Search

[Resolved] mpp_register_media_size – image orientation

Tagged: 

  • Participant
    Level: Initiated
    Posts: 14
    bayshanac on #337

    Hello,

    When I want to change size of thumbnail with this piece of code, some images with portrait orientation being rotate to landscape. Any idea?

    add_action( 'mpp_init', 'homepage_mpp_custom_thumbnail_size');
    function homepage_mpp_custom_thumbnail_size(){
     mpp_register_media_size( array(
                'name'  => 'thumbnail',
                'height'=> 800,
                'width' => 800,
                'crop'  => false,
                'type'  => 'default' //applies to all media
        ) );
    }
    
  • Participant
    Level: Initiated
    Posts: 14
  • Keymaster
    (BuddyDev Team)
    Posts: 24212
    Brajesh Singh on #342

    Hi Aleksandar,
    Thank you for asking.

    1. You have registered the size correctly. Good find there 🙂

    2. We are using WP_Image_Editor and it’s multi resize method for resizing, so I don’t see a direct way to change the crop. There is still a way to do it though.

    a). Please look at the documentation of WP_Image_Editor class here( and the first example is enough for us)
    https://codex.wordpress.org/Class_Reference/WP_Image_Editor

    Please do note, If you don’t pass any file name to save method, It saves to the original image.

    You can filter on

    
    
    mpp_generate_metadata
    
    

    filter in core/storage/loca-storage.php
    https://github.com/buddydev/mediapress/blob/master/core/storage/local-storage.php#L466

    and filter for the specific size and regenerate that( all the sized images are stored under $metadata[‘sizes’] )

    Hope that helps.

  • Participant
    Level: Initiated
    Posts: 14
    bayshanac on #351

    Hello,

    I found this piece of code in local-storage.php but could not find the solution. Do you can help me with more specific info?

    Is this Issue appears only on my website or somebody else has same problem?

    Thank you!

  • Keymaster
    (BuddyDev Team)
    Posts: 24212
    Brajesh Singh on #355

    Before assisting further, May I ask a question:-
    1. do you want to fix the wrong orientation problem on iOS devices? or do you want to do the rotate & crop thing.

    First is a generic issue and I can put a fix in the core, for second, I will need to share the code here.

    Please let me know.

  • Participant
    Level: Initiated
    Posts: 14
    bayshanac on #361

    Hello Brajesh,

    I appreciate your desire to help me.

    Biggest Issue I have so far is that MediaPress rotates some (not every) portrait images to became landscape. This Issue appeared me on more different devices and OS (Chrome, Firefox, iOS, Windows, Android). I think that maybe this can be related with “JPEG Rotation and EXIF Orientation”. I just guess, maybe I’m wrong.
    You can see one of the “problematic” images from the example in above post:
    Before: https://povezise.rs/dev/wp-content/uploads/mediapress/members/10/123/20140816_121308.jpg
    After: https://povezise.rs/dev/wp-content/uploads/mediapress/members/10/123/20140816_121308-800×450.jpg

    Another Issue I posted in topic “Mediapress – upload image from mobile device”.

  • Keymaster
    (BuddyDev Team)
    Posts: 24212
    Brajesh Singh on #363

    Hi Aleksandar,
    It is definitely the “JPEG Rotation and EXIF Orientation” issue. We haven’t put any mechanism to check for that and relay on default WordPress implementation( which suffers from same if I remember correctly).

    I will put a fix for the rotation by in tomorrow’s update.

    Thank you
    Brajesh

  • Participant
    Level: Initiated
    Posts: 14
    bayshanac on #368

    Hello Brejash,

    In the meantime I read about this WordPress Issue (https://wordpress.org/support/topic/image-exif-orientation-fix) and found this plugin https://wordpress.org/plugins/image-rotation-fixer/ which is fix this Issue on entire WordPress site.

    When you update MediaPress I will implement your fix on website.

    Thank you!

  • Keymaster
    (BuddyDev Team)
    Posts: 24212
    Brajesh Singh on #371

    Thank you.
    I will push it tonight Indian time with 2 other changes.

  • Keymaster
    (BuddyDev Team)
    Posts: 24212
    Brajesh Singh on #375

The topic ‘ [Resolved] mpp_register_media_size – image orientation’ is closed to new replies.

This topic is: resolved