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

Rename the insert button in media upload window

I think, this is not so easy possible, on the media-page in Admin-area is it not possible to check the post_type of your CPT. Normaly you can change strings with the follow small source, an example. if ( is_admin() ) add_filter( ‘gettext’, array( ‘fb_string_translate’, ‘gettext_filter’ ), 10, 1 ); class fb_string_translate { static function gettext_filter( … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)