Change filename during upload

If you want to use the above sanitize_file_name filter, you could try this: function make_filename_hash($filename) { if( isset($_REQUEST[‘post_id’]) ) { $post_id = (int)$_REQUEST[‘post_id’]; }else{ $post_id=0; } $info = pathinfo($filename); $ext = empty($info[‘extension’]) ? ” : ‘.’ . $info[‘extension’]; $name = basename($filename, $ext); if($post_id>0){ return $post_id.”_”.$name . $ext; }else{ return $name . $ext; } } add_filter(‘sanitize_file_name’, … Read more

post_author for wp_insert_attachment

My question is, is there a way to add a post_author to the wp_insert_attachment? I could not find that in the documentation. I need the attachment to have the same author id as that of the post. Currently it takes the id of the the admin. Sometimes the codex or published docs don’t tell the … Read more

How To Grab All Type Of Attachments, But Images?

WordPress has a function, get_allowed_mime_types, which will return all allowed types. We can filter this list and exclude any types containing image, then query for all remaining types by passing them as a comma separated list to post_mime_type. This may not be the most efficient way to do it, you may be better off filtering … Read more

Link all WordPress images size

You can do this by adding this function to your funcitons.php file. function my_get_image_size_links() { /* If not viewing an image attachment page, return. */ if ( !wp_attachment_is_image( get_the_ID() ) ) return; /* Set up an empty array for the links. */ $links = array(); /* Get the intermediate image sizes and add the full … Read more

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