Getting ID from ajax response of async-upload.php

I could but i really don’t want to post the work of others here, even if it’s open source code. Rilwis Meta Box Class has a plupload field, which has a custom upload handler. If you mind to take a look: https://github.com/rilwis/meta-box resp: https://github.com/rilwis/meta-box/blob/master/inc/fields/plupload-image.php#L31 The answer is there. This code,or at least the idea, gives … Read more

How to protect media directory with .htaccess?

# Only allow access to this directory if they are coming from your domain; excluding you, your server, Google and any other IPs RewriteEngine On RewriteCond %{REMOTE_ADDR} !^(xxx\.xxx\.xxx\.xxx|xxx\.xxx\xxx\.xxx|66\.249\.) RewriteCond %{HTTP_HOST} !^(127\.0\.0\.0|localhost) [NC] RewriteCond %{HTTP_REFERER} !^https?://(.+\.)?yourdomain\.com/ [NC] RewriteRule .* http://yourdomain.com/ [L] That should help, I think

Getting Details Of Uploaded Image

The attachment metadata stored for the image is: Array ( [width] => 558 [height] => 771 [hwstring_small] => height=”62″ width=”128″ [file] => 2012/02/logo2.png [sizes] => Array ( [thumbnail] => Array ( [file] => file_name.png [width] => 150 [height] => 150 ) [medium] => Array ( [file] => logo2-300×145.png [width] => 300 [height] => 145 ) … Read more

Adding a querystring to an image URL when clicking ‘insert into post’?

You need to use the filter image_send_to_editor. add_filter(‘image_send_to_editor’, ‘wpse_62869_img_wrapper’, 20, 8); function wpse_62869_img_wrapper( $html, $id, $caption, $title, $align, $url, $size, $alt ) { return $html; } These are the values of a test insert and you can use them to build your own $html response. html | <a href=”http://wp34.dev/wp-content/uploads/2012/11/escritorio.jpg”><img src=”http://wp34.dev/wp-content/uploads/2012/11/escritorio-224×300.jpg” alt=”Alt text for the image” … Read more

Close the media-upload thickbox right after upload is finished?

This was solved as simply as: Hooking a custom .js script to the media-upload thickbox, so that it runs inside the iFrame: function admin_styles_scripts_media_upload() { wp_register_script(‘mediajs’, get_template_directory_uri().’/js/button.js’, array(‘jquery’), true); wp_enqueue_script(‘mediajs’); } add_action(‘admin_print_scripts-media-upload-popup’,’admin_styles_scripts_media_upload’); ?> Use the script to replace the default Save button with a custom one, and call self.parent.tb_remove from that: jQuery(document).ready(function() { jQuery(‘<a href=”#” … Read more

Bug when uploading pictures with international characters?

That is a bit odd, and I can’t reproduce your error. Perhaps it has something to do with differnt character encodings of the filename/filesystem you are uploading from or to. When handling file uploads WordPress sanitizes the file name to remove spaces and some other unwanted characters. This sanitizing is performed by sanitize_file_name when the … Read more

Proper way to hook wp_get_attachment_url

Hook wp_get_attachment_link for this purpose. Here is an example of how to do it – function attachment_link_filter( $content, $post_id, $size, $permalink ) {       // Only do this if we’re getting the file URL     if (! $permalink) {         // This returns an array of (url, width, height)         $image = wp_get_attachment_image_src( $post_id, ‘large’ );         $new_content = … Read more

Media handle sideload not working

For those having similar problem, I cleared web-server’s /tmp partition being filled with temp files. The root cause was actually that my hosting provider sets the /tmp partition to be 128MB when on their VPS, which is far too small for the size of uploads that I want to be able to do.

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