Change categories count to include media attachments

You’ve probably solved this, but for anyone else that needs this: $wp_taxonomies[‘category’]->update_count_callback = ‘_update_generic_term_count’; This is significant in the case of attachments. Because an attachment is a type of post, the default _update_post_term_count() will be used. However, this may be undesirable, because this will only count attachments that are actually attached to another post (like … Read more

Automatically Insert Into Post when uploading Media

That’s the pre-3.5 media interface so I think you must be on 3.4.x? Anyway the first way should work as long as you’re using the browser (non-multifile) upload… try changing add_filter( ‘flash_uploader’, ‘_force_html_uploader’ ); to add_action( ‘pre-html-upload-ui’, ‘_force_html_uploader’ ); and the “js/upload.js” (note the subdirectory – it’s expected to be in a “js” subdirectory of … Read more

Disable image rename on upload

The renaming to test1.jpg is not due to any cropping / resizing functions WordPress. This is because you already had a file named test.jpg uploaded, and WordPress does not replace files if one exists in the folder that has the same name. If, for some reason you want it to replace files rather than rename … Read more

wp_enqueue_media() and upload_mimes problem

I think, first of all you should move following filter outside the function and then check – add_filter( ‘upload_mimes’, array( ‘JBLAB_Utils’, ‘images_upload_mimes’ ) ); Even if it does not work, try changing the priority of the filter.

How to get all inline images in post content? [duplicate]

Well you can do this 1 of 2 ways. $attachments = get_posts(array( ‘post_type’ => ‘attachment’, ‘numberposts’ => -1, ‘post_status’ => null, ‘post_parent’ => get_the_ID(), ‘order’ => ‘ASC’, ‘orderby’ => ‘id’, )); And then manipulate the array to remove duplicates. Another option would be to apply a content filter, and use a regex to find and … Read more

Adding .mov files (not from YouTube) [duplicate]

You can use upload_mimes filter and add mime for .mov files (video/quicktime). add_filter( ‘upload_mimes’, ‘customizeMimeTypes’, 10, 1 ); function customizeMimeTypes( $mimeTypes) { $mimeTypes[‘mov’] = ‘video/quicktime’; return $mimeTypes; } If you want to embed video with media library you can use wp_video_extensions filter. add_filter( ‘wp_video_extensions’, ‘addMovToWPVideo’); function addMovToWPVideo( $extensions ) { $extensions [] = ‘mov’; return … Read more

Custom upload folder

Use something like this function, you need to set condition for if(user==admin) and then if(post-type==’some-post-type’): function wpse_16722_type_upload_dir( $args ) { // Get the current post_id $id = ( isset( $_REQUEST[‘post_id’] ) ? $_REQUEST[‘post_id’] : ” ); if( $id ) { // Set the new path depends on current post_type $newdir=”https://wordpress.stackexchange.com/” . get_post_type( $id ); $args[‘path’] … Read more

limit media upload to once a day

You will need to create a meta field for users identifying that user when he already uploaded something in that day (or in the last 24 hours). After you do that, you will need to create a function to trigger in some upload action, like wp_handle_upload_prefilter or wp_handle_upload to check if user can upload something … Read more

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