Set spesific size of featured images

In your functions.php you want to issue a call to set_post_thumbnail_size() https://codex.wordpress.org/Function_Reference/set_post_thumbnail_size As with add_image_size, you provide the target width, height & whether you want the image hard cropped to these dimensions. So, for example, set_post_thumbnail_size(427, 427, true); will crop all your thumbnails to be a maximum of 427px high or wide, depending on aspect … Read more

How to get file URL from media library

If you check the documentation for media_sideload_image() it returns HTML img tag for the image right away. Alternately it can return just the URL. Note that while this is suitable for immediate use, it’s generally challenging to go back from URL to attachment ID. IDs are much more friendly for many things, such as being … Read more

WordPress converts media extention URL automatically to video player

You should consider using the Auto-embeds Disabler plugin here: https://gist.github.com/ocean90/3796628 Note that it’s actually just a single line of code, if you prefer to add that to your functions.php – but I’d suggest keeping it as a plugin so you can easily activate/deactivate that functionality. remove_filter( ‘the_content’, array( $GLOBALS[‘wp_embed’], ‘autoembed’ ), 8 ); Note that … Read more

Can I Change the Media Upload Location for each user?

the easy way is using this: // $filename should be the path to a file in the upload directory. $filename=”2016/09/1.jpg”; // The ID of the post this attachment is for. $parent_post_id = 32; // Check the type of file. We’ll use this as the ‘post_mime_type’. $filetype = wp_check_filetype( basename( $filename ), null ); // Get … Read more