Metabox image upload value

It appears that $field[‘custom_image’] isn’t passing what you want it to. The returned values do not appear to be correct. You want to put the key of the meta value you need as the second variable in the get_post_meta() function, for example: $image_upload = get_post_meta($post->ID, ‘_my_image_id’, true); Each custom meta field you create has a … Read more

How to remove a tab in Media Upload page in wordpress

I’m not sure it has to do with enqueueing, if all you want to do is hide the Media Library tab in the media upload window. I found the following solution (haven’t tried it myself): function remove_media_library_tab($tabs) { unset($tabs[‘library’]); return $tabs; } add_filter(‘media_upload_tabs’, ‘remove_media_library_tab’); The link contains some more details as to why this is … Read more

Image not showing up in media loader success area – followup

untested, but it should work theoretically: add_filter(‘get_attached_file’, function($path, $file, $attachment_id){ // get the post object of the current attachment $att = get_post($attachment_id); // prepend attachment post parent ID to the file name return substr_replace($path, “{$att->post_parent}/{$file}”, -strlen($file)); }); Another filter, attempts to “fix” the path returned by WP’s upload handler: add_filter(‘wp_handle_upload’, function($results){ global $post; if(empty($post)) return … Read more

Unable to upload data to Media Libary

function load_scripts() { wp_deregister_script(‘jquery’); wp_register_script(‘jquery’, (“http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js”)); wp_enqueue_script(‘jquery’); } add_action(‘init’, ‘load_scripts’); I have found the problem now (for all the following readers). In my template functions.php I’ve included the latest version of jQuery. So jQuery has been included in the admin panel too. The fact that WordPress loads jQuery in the admin panel twice must have … Read more

How to take large file uploads from users the right way

The right way is entirely dependent on what limitations you want to place on your users. WordPress ships with a library called plupload. This is what powers the multi-file uploader in core, and it’s available to create your own upload tools as well. The beneficial feature of plupload is the ability to chunk files on … Read more

Limit image upload to 10

here you go: get_posts(array(‘post_type’=>’attachment’, ‘numberposts’ => 10, ‘post_parent’ => $post_id)); this will return you upto 10 posts.