How to add new tab to media upload manager with custom set of images?

This is an old thread but for me still as still as relevant. I have been fiddling and has come up with this code for adding a media tab here, maybe someone want to continue for how the handle content for the tab? 🙂 add_action(‘admin_enqueue_scripts’, function(){ wp_enqueue_script( ‘my-media-tab’, plugin_dir_url( __FILE__ ) . ‘/js/mytab.js’, array( ‘jquery’ … Read more

Limit image upload to one and disable audio, video and other document file types to upload

I was about to give up thinking that it wasn’t possible or at least easy and then I stumbled onto the wp_handle_upload_prefilter filter which gives you exactly what you asked for! Here’s the code: add_filter(‘wp_handle_upload_prefilter’, ‘yoursite_wp_handle_upload_prefilter’); function yoursite_wp_handle_upload_prefilter($file) { // This bit is for the flash uploader if ($file[‘type’]==’application/octet-stream’ && isset($file[‘tmp_name’])) { $file_size = getimagesize($file[‘tmp_name’]); … Read more

How to generate thumbnails when needed only?

Take a look at Otto’s Dynamic Image Resizer plugin This plugin changes the way WordPress creates images to make it generate the images only when they are actually used somewhere, on the fly. Images created thusly will be saved in the normal upload directories, for later fast sending by the webserver. The result is that … Read more

wp_upload_dir how to get just the directory name .

This is what you get back from the function: Array ( [path] => C:\development\xampp\htdocs\example.com/content/uploads/2012/04 [url] => http://example.com/content/uploads/2012/04 [subdir] => /2012/04 [basedir] => C:\~\example.com/content/uploads [baseurl] => http://example.com/content/uploads [error] => ) So you can get the (as @OneTrickPony pointed out), folder/directory name with echo wp_basename( $uploads[‘baseurl’] ); If you’re running multisite and you defined the constant UPLOADS, … Read more

Can I upload media to a specific folder?

Go to Dashboard -> Settings -> Media Enter the desired location in Store uploads in this folder Uncheck Organize my uploads into month- and year-based folders This will specify the global upload location. To specify a per-file upload location, you’ll need to use a Plugin, such as WP Easy Uploader (not an endorsement, per se; … Read more

Physical organization of wordpress media library (Real Media Library plugin)

Free solution extension “Physical Custom Upload Folder” A long time ago I started to open this thread and now there is a usable extension plugin for Real Media Library which allows you to physically manage your uploads folder. Check out this plugin: https://wordpress.org/plugins/physical-custom-upload-folder/ Do you know the wp-content/uploads folder? There, the files are stored in … Read more

Image Upload from URL

you can write a php script, or make your own plugin of this code here, i used it in one of my projects where i had to import a large number of images. first, get the image, and store it in your upload-directory: $uploaddir = wp_upload_dir(); $uploadfile = $uploaddir[‘path’] . “https://wordpress.stackexchange.com/” . $filename; $contents= file_get_contents(‘http://mydomain.com/folder/image.jpg’); … Read more

Trigger refresh for new media manager in 3.5

The correct way of refreshing the content of the frame, as found in the WP core, is as below: if(wp.media.frame.content.get()!==null){ wp.media.frame.content.get().collection.props.set({ignore: (+ new Date())}); wp.media.frame.content.get().options.selection.reset(); }else{ wp.media.frame.library.props.set({ignore: (+ new Date())}); } You should always check of the content is available, else refresh the library. Cheers!

How to Fix HTTP Error When Uploading Images?

I put the following code into my functions.php file. It works! add_filter( ‘wp_image_editors’, ‘change_graphic_lib’ ); function change_graphic_lib($array) { return array( ‘WP_Image_Editor_GD’, ‘WP_Image_Editor_Imagick’ ); } When this helps it is because it changes the PHP code module used for processing the uploaded image for use with WordPress. This processing includes moving the image into the media … Read more

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