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

Programmatically adding images to media library

$image_url=”adress img”; $upload_dir = wp_upload_dir(); $image_data = file_get_contents( $image_url ); $filename = basename( $image_url ); if ( wp_mkdir_p( $upload_dir[‘path’] ) ) { $file = $upload_dir[‘path’] . “https://wordpress.stackexchange.com/” . $filename; } else { $file = $upload_dir[‘basedir’] . “https://wordpress.stackexchange.com/” . $filename; } file_put_contents( $file, $image_data ); $wp_filetype = wp_check_filetype( $filename, null ); $attachment = array( ‘post_mime_type’ => … 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

Get All Images in Media Gallery?

$query_images_args = array( ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’, ‘post_status’ => ‘inherit’, ‘posts_per_page’ => – 1, ); $query_images = new WP_Query( $query_images_args ); $images = array(); foreach ( $query_images->posts as $image ) { $images[] = wp_get_attachment_url( $image->ID ); } All the images url are now in $images;

Change the default-view of Media Library in 3.5?

There were two minor mistakes in my previous answer: I forgot to trigger the change event for the parent. I called the function on every AJAX call, making other selections impossible. Here is the fixed code: <?php /** * Plugin Name: Pre-select post specific attachments */ add_action( ‘admin_footer-post-new.php’, ‘wpse_76048_script’ ); add_action( ‘admin_footer-post.php’, ‘wpse_76048_script’ ); function … Read more

Add a menu item to WordPress 3.5 Media Manager

OK, I think that I have something that is really close to be an answer: I put my code in a gist Here is the result : I built several Backbone object to respect the MVC pattern : the controller.Custom is in charge of doing all the logic, the view.Toolbar.Custom deals with toolbar buttons, and … Read more

How to Protect Uploads, if User is not Logged In?

Only checking if the cookie exists, is not much of a strict protection. To get a stronger protection, you can pass or “proxy” all requests to the uploaded folder (exemplary uploads in the following example) through a php script: RewriteCond %{REQUEST_FILENAME} -s RewriteRule ^wp-content/uploads/(.*)$ dl-file.php?file=$1 [QSA,L] All requests to uploaded files (which includes images in … Read more

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