Disable TinyMCE Drag and Drop

you can solve this problem by enqueue the following script with the dependency of jQuery jQuery(document).ready(function(){ tinyMCEPreInit.dragDropUpload = false; }); To add the dependency you can refer this link I have tested this solution and it has worked for me. I hope it will work for you too.

Filter Media Library by author or post_parent

The only way to do it is using a query filter I think function wpse156319_posts_where( $where, $query ) { global $wpdb; $where .= $wpdb->prepare( ‘ AND (‘ . $wpdb->posts . ‘.post_parent = %s OR ‘ . $wpdb->posts . ‘.post_author = %s)’, $_POST[‘id’], get_current_user_id() ); return $where; } which you just add in the ajax_query_attachments_args instead … Read more

Shortlink directly to a media file?

It turns out this is easily solved by creating a file attachment.php and redirecting to the file itself. Create an attachment.php file in your WordPress theme folder Put this code in the file <?php wp_redirect(wp_get_attachment_url(), 301); ?> Upload it and there you go This link explains in full.

How to validate the file name of the Media File Uploads?

The filter is sanitize_file_name. You get the $filename as parameter. Sample code: add_filter( ‘sanitize_file_name’, ‘wpse_77892_filter_filename’ ); function wpse_77892_filter_filename( $filename ) { return str_replace( ‘%’, ‘-‘, $filename ); } See my plugin Germanix URL for an extended example.

Extend 3.5 media uploader plugin to change button name

Figured it out using a different method. Help from here. $.fn.oeUpload = function(options) { // Set default options var defaults = { ‘preview’ : ‘.preview-upload’, ‘text’ : ‘.text-upload’, ‘button’ : ‘.button-upload’, ‘name’ : ‘Choose Image’ }; var options = $.extend(defaults, options); var uploader; $(options.button).click(function(e) { e.preventDefault(); //If the uploader object has already been created, reopen … Read more

Delete attachments from Front end

You can do it via ajax, first, let’s change your current function to this: <?php $args = array( ‘order’ => ‘ASC’, ‘orderby’ => ‘menu_order’, ‘post_type’ => ‘attachment’, ‘post_parent’ => $post->ID, ‘post_mime_type’ => ‘image’, ‘post_status’ => null, ‘numberposts’ => -1, ); $images = get_posts( $args ); $imagenum=0; foreach($images as $image): $imagenum++; ?> <div style=”width:110px; float:left;”> <?php … Read more

Modify the array of selected images in media modal

I’m able to do the following in media modal: var selection = wp.media.frame.state().get(‘selection’); // get selected collection attachment = wp.media.attachment(id); // get attachment with id attachment.fetch(); selection.add(attachment); // add attachment to selection collection There should be .remove() method or something similar.

Ignore a filter on the media library

You can use is_admin() in conjunction with the admin global variable $pagenow to make sure you’re not on either the upload or media page: function remove_images( $where ) { global $wpdb, $pagenow; if( is_admin() && in_array( $pagenow, array( ‘upload.php’, ‘media-upload.php’ ) ) { return $where } $where .= ” AND {$wpdb->posts}.post_mime_type NOT LIKE ‘image/%'”; return … Read more

Video embeds work in backend, but are not parsed in frontend

I’ve just looked at the source of the WP_Embed class, and it appears they are not actually registering a shortcode, but hooking into the the_content filter. Change your code to $content_desktop = apply_filters(“the_content”, get_the_content()); or manually trigger their filter with something like $content_desktop = WP_Embed::run_shortcode(get_the_content()); or, if you prefer to have an object: $myembeds = … Read more

How to add a category or tag to media at upload time with the browser uploader?

I’ve been using Media Tags plugin with much success – it was very useful for retrieving images belonging to certain page with specific tags with following code: $results = get_attachments_by_media_tags(array(“media_tags”=>”gallery”, “post_parent” => $global_id, “order” => “ASC”)); Of course you can easily tag anything that sits in your media library (I wasn’t even aware that you … Read more

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