Add custom image sizes to media uploader

Invalid argument supplied for foreach means that the X in foreach X as … is not an array. You can prevent this error by type casting; add (array) before the argument in the foreach statement. This will turn your variable into an array, essentially. In your code, the change would be… foreach ( (array) $attach_meta[‘sizes’] … Read more

Upload images using FTP and show them in media

I know it’s one year old but just in case someone else is also searching: You could upload the main files (not all 3 sizes, just the original images) via FTP to another directory on your server and then use the Add-From-Server Plugin.

Way to display media library in frontend

As far I’ve understood with those I’ve written a simple system for you. Please put the below codes in your functions.php– add_action( ‘wp_enqueue_scripts’, ‘the_dramatist_enqueue_scripts’ ); add_filter( ‘ajax_query_attachments_args’, ‘the_dramatist_filter_media’ ); add_shortcode( ‘the_dramatist_front_upload’, ‘the_dramatist_front_upload’ ); /** * Call wp_enqueue_media() to load up all the scripts we need for media uploader */ function the_dramatist_enqueue_scripts() { wp_enqueue_media(); wp_enqueue_script( ‘some-script’, … Read more

Moving Categories submenu to Media, but still opens Posts menu

To add to what @brasofilo answered 3 years ago, this is what is necessary in the current menu system (WP v4.5.1). add_action( ‘admin_head-edit-tags.php’, ‘modify_menu_highlight_wpse_43839’ ); function modify_menu_highlight_wpse_43839() { if( ‘post_tag’ == $_GET[‘taxonomy’] ) { ?> <script type=”text/javascript”> jQuery(document).ready( function($) { $(“#menu-posts, #menu-posts a”) .removeClass(‘wp-has-current-submenu’) .removeClass(‘wp-menu-open’) .addClass(‘wp-not-current-submenu’); $(“#menu-media, #menu-media > a”) .addClass(‘wp-has-current-submenu’); }); </script> <?php } … Read more

How to Removing fields from the Media Uploader/Gallery on a Custom Post Type Edit Page

The current screen doesn’t appear to be set when that filter is run, so you cannot use that. Also, the $post actually refers to the attachment, not the post – so we can’t get the post typ fro that either…. So looking at the source code: http://core.trac.wordpress.org/browser/tags/3.3.2/wp-admin/includes/media.php The filter you are using is called by … Read more

Increase Size Limit of Media Files WordPress 4.1

The limiting factor appears to be in your .htaccess file: php_value post_max_size 1M The post_max_size needs to be at least equal to the upload_max_filesize, so increase that to 100M. The settings in .htaccess should override the settings in php.ini. Edit: If that doesn’t work, and since you have full root privileges, you can modify the … Read more