How to change the image size in new Media Uploader (ie use medium vs thumbnail)

Supposing that I’m interpreting your Question correctly… The thumbnails displayed in the new Media Uploader are already the medium sized ones, being constrained on the fly. So, it’s a matter of applying some CSS styling to increase their size. Maybe other style adjustments are necessary, this is just a proof of concept. add_action( ‘admin_head-post-new.php’, ‘style_thumbnails_wpse_81677’ … Read more

Issue on Running Image upload on WP Metabox Custom Image Loader

I had the same error because I forgot to add: wp_enqueue_media(); Then I found this how to and solved the problem like this: 1: You have to enqueue WP JavaScript library for media and your own JS file: public function enqueue_scripts() { //WP library wp_enqueue_media(); //Your JS file wp_register_script(‘name-of-your-script’, plugin_dir_url( __FILE__ ) . ‘js/path-to-your.js’, array( … Read more

WordPress site stuck at 1MB for max file size

I had the very same problem. None of googled articles suggesting trivial solutions (like “resize image”, “wait a bit”) helped. Symptoms: media uploading works perfectly, but only for some files (larger than 1Mb) the “HTTP error” occurs. But when I tried to check my web server logs, everything became clear in one second. I suppose … Read more

Post Specific Uploader

Check if the argument is present, and if it isn’t return the default value: if(!isset($_REQUEST[‘post_id’])) return $upload; // cast it to integer to avoid problems $id = (int)$_REQUEST[‘post_id’]; …

How Can I pass an image file to wp_handle_upload?

wp_handle_upload() is made to handle, well, uploads. It expects upload-related inputs. To “upload” image from remote URL there is media_sideload_image(). Since you actually don’t specify type of your file, you might need to tinker some yourself, using this function as an example.

Accessing Media/Files outside the_content

Try the following code: $args = array( ‘post_type’ => ‘attachment’, ‘numberposts’ => -1, ‘post_status’ => null, ‘post_parent’ => $post->ID ); $attachments = get_posts( $args ); if ($attachments) { foreach ( $attachments as $attachment) { setup_postdata($attachment); the_title(); the_attachment_link($attachment->ID, false); the_excerpt(); } }

Add file extension to temporary file

The problem: When you download an image with an extension, for example jsbach_image.jpg, it will look like this in the temp directory: /tmp/jsbach.tmp but when you download an image without an extension, for example mozart_image, you will get: /tmp/mozart But the latter one will not pass the filetype- and extension tests in the wp_handle_sideload() function, … Read more