Upload specific images to specific folder

In your answer you said that desired path is something like wp-content\uploads\state-name\destination\ where state-name is a taxonomy term and destination is the slug of one destination CPT. Last thing is not clear from your question, but it seems so, let me know if I’m wrong). So, I suggest you this workflow: Add a destination post … Read more

media_handle_upload for local files?

You want media_handle_sideload() Handles a side-loaded file in the same way as an uploaded file is handled by media_handle_upload(). // Array similar to a $_FILES upload array. $file_array = array( ‘name’ => ‘filename.jpg’, ‘tmp_name’ => ‘path/to/filename.jpg’, ); // Post ID to attach upload to, 0 for none. $post_id = 0; $attachment_id = media_handle_sideload( $file_array, $post_id … Read more

Set media upload attachment link to none and hide it in WP v3.5

Include this small plugin, activate and test. A tested version in 3.6-alpha, works only on click on a thumbnail. <?php /** * Plugin Name: Remove Attachment Link-To and set to value ‘none’ */ add_action( ‘admin_footer-post-new.php’, ‘wpse_76214_script’ ); add_action( ‘admin_footer-post.php’, ‘wpse_76214_script’ ); function wpse_76214_script() { ?> <script type=”text/javascript”> jQuery(document).ready( function($) { $( ‘li.attachment’ ).live( ‘click’, function( … Read more

What is the best practice for renaming WordPress media files?

As Rarst has explained, you can’t really directly edit your database, or you’ll risk killing the serialized data. Your options are thus to: delete the file and re-upload it with its new name (obviously has the downside of having to reinsert it everywhere it was being used), or to use one of the media renaming … Read more

Differentiate Featured Image from Post Images upon Upload

You could do this by filtering the meta value for _thumbnail_id. add_filter( ‘update_post_metadata’, ‘generate_featured_image_sizes’, 10, 5 ); add_filter( ‘add_post_metadata’, ‘generate_featured_image_sizes’, 10, 5 ); function generate_featured_image_sizes( $check, $object_id, $meta_key, $meta_value, $unique_or_prev ) { if ( $meta_key == ‘_thumbnail_id’ ) { // regenerate previous featured image thumbs if it exists if ( false !== ( $prev_thumb_id = … Read more