Media Library Cleanup A Thought Exercise
Media Library Cleanup A Thought Exercise
Media Library Cleanup A Thought Exercise
The problems turned out to have something to do with the sortable columns function I wrote before. Please see the function below. function cpt_date_orderby( $query ) { $orderby = $query->get( ‘orderby’ ); if( ‘date’ == $orderby ) { $query->set(‘meta_key’, ‘date’); $query->set(‘orderby’, ‘meta_value_num’); } } add_action( ‘pre_get_posts’, ‘cpt_date_orderby’ ); The problem lies in line 3 where … Read more
I had to implement the following: Change the admin UI to include my custom filters add_action(‘wp_enqueue_media’, function () { wp_enqueue_script(‘media-library-taxonomy-filter’, get_stylesheet_directory_uri() . ‘/assets/js/custom-media-filter.js’, array(‘media-editor’, ‘media-views’)); }); In the custom-media-filter.js I am appending the custom select HTML and every time my custom select is changed, add the query parameters in the URL and redirect with this … Read more
Thumbnail (featured image) and Media Library cleanup queries help needed
Save data is post using php front end
add_filter( ‘intermediate_image_sizes_advanced’, function ( $sizes ) { $allowed = [ ‘thumbnail’, ‘medium’, ‘large’, ‘medium_large’ ]; foreach ( $sizes as $name => $size ) { if ( ! in_array( $name, $allowed ) ) { unset( $sizes[ $name ] ); } } return $sizes; } ); I ended up setting an array with the crops I would … Read more
function add custom fields to media gallery
When you upload an image to WordPress, it generates three image sizes by default (thumbnail, medium, and large). Put simply, WordPress automatically resizes images to help you save bandwidth and prevent you from having to manually resize images. For example, the image size you would use for a thumbnail is much different than what you … Read more
WordPress fires admin_enqueue_scripts hook earlier, than add_options_page, where you put your admin_enqueue_scripts. Solution is simple, you need to put your admin_enqueue_scripts hook outside of the add_options_page function callback. function load_wp_media(){ wp_enqueue_media(); wp_enqueue_script( ‘waterStampScript’, plugin_dir_url( __FILE__ ) . ‘js/app.js’, array(‘jquery’)); } add_action( ‘admin_enqueue_scripts’, ‘load_wp_media’ );
There seems to be no official hooks that effect media widgets. It is possible to access the properties of the widgets in the sidebar using the dynamic_sidebar_params hook in combination the $wp_registered_widgets global widget array. However, there is no image widget property for setting the inline styling of the image. Therefore the simplest solution to … Read more