Tagged: mediapress
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 ) ); }
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_EditorPlease 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#L466and filter for the specific size and regenerate that( all the sized images are stored under $metadata[‘sizes’] )
Hope that helps.
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.
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.jpgAnother Issue I posted in topic “Mediapress – upload image from mobile device”.
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
BrajeshHello 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!
Thank you.
I will push it tonight Indian time with 2 other changes.Hi,
Have fixed it here
https://github.com/buddydev/mediapress/commit/557e932ad2abe47450b3f13b128e2d27342b08de
Hope that helps.
The topic ‘ [Resolved] mpp_register_media_size – image orientation’ is closed to new replies.