Pulling images from a subdomain

Managed to solve it myself.. So if anyone else has this problem. Because the sub-domain is still under the main domain you do not have to put – /home/hostname/subdomain.com you only need the /home/sub-domain.com and everything will work.. hope this helps someone.. Richard

Featured images get shrunken

Hey if you want to add custom image size then add the following code in your function.php file add_image_size( ‘thumb’, 220, 180, true ); and then call featured image in your template like this <?php if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it. the_post_thumbnail(‘thumb’); } ?> … Read more

How to change compression of WordPress uploads including original image

For compressing the uploaded image I wrote a simple code snippet that immediately overwrites a newly uploaded file with an image whose quality can be specified: function wt_handle_upload_callback( $data ) { $image_quality = 30; // Change this according to your needs $file_path = $data[‘file’]; $image = false; switch ( $data[‘type’] ) { case ‘image/jpeg’: { … Read more

Remove the ‘Attachment Details’ section of the wordpress media manager

I use CSS for that: add_action(‘admin_head-post.php’, ‘hide_media_stuff_wpse_120894’ ); add_action(‘admin_head-post-new.php’, ‘hide_media_stuff_wpse_120894’ ); function hide_media_stuff_wpse_120894(){ ?> <style type=”text/css”> .attachment-details [data-setting=”title”], .attachment-details [data-setting=”caption”], .attachment-details [data-setting=”alt”], .attachment-details [data-setting=”description”], div.attachment-display-settings { display:none } </style> <?php }

Media_handle_upload with custom upload folder?

If I’m not mistaken, then it should be possible. You want to use media_handle_upload(), which calls wp_handle_upload() to handle the file upload. wp_handle_upload() on itself won’t be helpful, especially because it is pretty much just a wrapper for _wp_handle_upload(). It’s not the end yet, because inside _wp_handle_upload() the function wp_upload_dir() is called, where we find … Read more

Display image file size in media library

In your theme’s functions.php add the following code to get the file size for all of your items in the Media library: add_filter( ‘manage_upload_columns’, ‘wpse_237131_add_column_file_size’ ); add_action( ‘manage_media_custom_column’, ‘wpse_237131_column_file_size’, 10, 2 ); function wpse_237131_add_column_file_size( $columns ) { // Create the column $columns[‘filesize’] = ‘File Size’; return $columns; } function wpse_237131_column_file_size( $column_name, $media_item ) { // … Read more