Disable drag and upload in Media Library

Instead of removing upload script you can make the upload error out if the user does not have admin privileges. Like this- function tomjn_only_upload_for_admin( $file ) { if ( ! current_user_can( ‘manage_options’ ) ) { $file[‘error’] = ‘You can\’t upload images without admin privileges!’; } return $file; } add_filter( ‘wp_handle_upload_prefilter’, ‘tomjn_only_upload_for_admin’ ); For other possible … Read more

Image upload via FTP to wordpress media library

You can upload your images to your host, and then use media_sideload_image() to upload each file. Let’s assume you upload all of your images to a folder named wpse, in the root of your WordPress installation: // Set the directory $dir = ABSPATH .’/wpse’; // Define the file type $images = glob($directory . “*.jpg”); // … Read more

Check if image exists before uploading with media_sideload_image()

I wonder if you’re looking for the core attachment_url_to_postid() function that uses: $sql = $wpdb->prepare( “SELECT post_id FROM $wpdb->postmeta WHERE meta_key = ‘_wp_attached_file’ AND meta_value = %s”, $path ); $post_id = $wpdb->get_var( $sql ); Note the extra meta key _wp_attached_file check compared to your current snippet. If you need to check if an image url … Read more

Change WordPress’ media upload URL?

It was actually easier than I thought. function route_uploads_past_cdn( $url, $path ) { $upload_paths = array( ‘async-upload.php’, ‘media-new.php’ ); if( !in_array( $path, $upload_paths ) ) { return $url; } return str_replace(‘www.’, ”, $url); } add_filter( ‘admin_url’, ‘pew_route_uploads_past_cdn’, 10, 2 ); The URL for uploading media would normally be http://www.example.com/wp-admin/media-new.php would now be http://example.com/wp-admin/media-new.php since the … Read more

Uploading an image as featured image from frontend form

I have found the problem. Problem was in a .js file. This code is causing the problem : $et_contact_form.live(‘submit’, function() { et_contact_error = false; et_message=”<ul>”; $et_inputs.removeClass(‘et_contact_error’); $et_inputs.each(function(index, domEle){ if ( jQuery(domEle).val() === ” || jQuery(domEle).val() === jQuery(this).siblings(‘label’).text() ) { jQuery(domEle).addClass(‘et_contact_error’); et_contact_error = true; var default_value = jQuery(this).siblings(‘label’).text(); if ( default_value == ” ) default_value = … Read more

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