How to restrict images in v3.5 Media Library modal to only those from a specific post id?

I am not sure is this what you are looking for. This code will “lock” uploads to show only “Uploaded to this post” in media panel add_action( ‘admin_footer-post-new.php’, ‘firmasite_mediapanel_lock_uploaded’ ); add_action( ‘admin_footer-post.php’, ‘firmasite_mediapanel_lock_uploaded’ ); function firmasite_mediapanel_lock_uploaded() { ?> <script type=”text/javascript”> jQuery(document).on(“DOMNodeInserted”, function(){ // Lock uploads to “Uploaded to this post” jQuery(‘select.attachment-filters [value=”uploaded”]’).attr( ‘selected’, true ).parent().trigger(‘change’); … Read more

Is it possible to allow zip files to be uploaded in WordPress?

Here is a action that works on my site: add_filter(‘upload_mimes’, ‘custom_upload_mimes’); function custom_upload_mimes ( $existing_mimes=array() ) { // add your extension to the mimes array as below $existing_mimes[‘zip’] = ‘application/zip’; $existing_mimes[‘gz’] = ‘application/x-gzip’; return $existing_mimes; }

Insert images to post not working

Have you enabled debugging in wp-config.php change define(‘WP_DEBUG’, false); to define(‘WP_DEBUG’, true); This will cause WordPress and php to generate a lot more error messages. With very little detail to go on, my first guess would be file permissions on the upload directory on your server.

Using same directory for storing all uploaded images on a WordPress network

You can pretty simple add some actions to archive this. function wpse_16722_main_uploads() { switch_to_blog(1); } add_action(‘load-media-new.php’, ‘wpse_16722_main_uploads’); add_action(‘load-media-upload.php’, ‘wpse_16722_main_uploads’); add_action(‘load-media.php’, ‘wpse_16722_main_uploads’); add_action(‘load-upload.php’, ‘wpse_16722_main_uploads’); add_action(‘admin_init’, ‘wpse_16722_main_uploads’); This will change the current sub-blog to user your main-site with the help of switch_to_blog and of course you want the main side by the id 1. You can also … Read more

How to wp_upload_bits() to a sub-folder?

wp_upload_bits() uses wp_upload_dir() which fires the upload_dir filter allowing you to modify the upload directory’s path, sub-directory and URL. So you can use that filter to “force” wp_upload_bits() to use a custom path by doing something like: // Demo to get the image data. $url=”https://logo.clearbit.com/starcomww.com”; $content = file_get_contents( $url ); $_filter = true; // For … Read more

Protecting direct access to PDF and ZIP unless user logged in (without plugin)

RewriteCond %{REQUEST_FILENAME} -s RewriteRule ^wp-content/uploads/([^/]*\.(pdf|zip))$ filecheck.php?file=$1 [QSA,L] This actually looks OK, except if you have additional subdirectories within the /uploads directory? An alternative is to include an additional condition on the original rule that only rewrites the request if the request ends in .pdf or .zip. For example: RewriteCond %{REQUEST_URI} \.(pdf|zip)$ [NC] RewriteCond %{REQUEST_FILENAME} -s … Read more

Add inline uploader to plugin option page

Okay, here is what I came up with: It’s all about using the plupload library that comes shipped with WP. 1. Add a <div> to your plugin’s option page that later becomes the drag’n’drop area <div class=”your-plugin-uploader multiple”> <input id=”your-plugin-uploader-button” type=”button” value=”<?php esc_attr_e( ‘Select Files’ ); ?>” class=”your-plugin-uploader-button button”> <span class=”ajaxnonce” id=”<?php echo wp_create_nonce( __FILE__ … Read more

retrieve custom image sizes from media uploader javascript object

thanks to a friend on Twitter, I was able to get this working. Below is the code. function wpse_110060_image_sizes_js( $response, $attachment, $meta ){ $size_array = array( ‘custom_size_one’, ‘custom_size_two’) ; foreach ( $size_array as $size ): if ( isset( $meta[‘sizes’][ $size ] ) ) { $attachment_url = wp_get_attachment_url( $attachment->ID ); $base_url = str_replace( wp_basename( $attachment_url ), … Read more

Image upload callback in new 3.5 media

There is a FileUploaded event being fired in wp-includes/js/plupload/wp-plupload.js. Alternatively (and propably the better way) you may want extend wp.Uploader with your own success callback . (function($){ $.extend( wp.Uploader.prototype, { success : function( file_attachment ){ console.log( file_attachment ); } }); })(jQuery);

Media not actually deleted on disk when click “Permanent Delete”

So, after several attempts… it is a problem (or a feature) of the WPML multilanguage plugin. To start with, I have set up correctly the user permissions, as @WebElaine mentioned. Just in case something was not configures properly. More information on the following articles: Permissions to wp-content folder in Windows Server 2012 https://www.chillies.co.za/news/4421/The-Correct-Permissions-for-WordPress-on-IIS/ https://www.customfitonline.com/news/2013/6/20/solve-wordpress-on-windows-server-problems/ In … Read more

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