Navigate with keyboard in Gallery shortcode

The Underscores (_s) starter theme comes with a keyboard navigation script for this. I haven’t tested this myself though. But the JS file looks like this: jQuery( document ).ready( function( $ ) { $( document ).keydown( function( e ) { var url = false; if ( e.which == 37 ) { // Left arrow key … Read more

Change the filename format of saved featured images

There is a filter to use for the array containing the filename that is saved to postmeta but since there are no filters available to change the filename before it is saved you have to manually change it using rename(). function wpse_filter_image_resize_name( $filename ) { $new_name = preg_replace( “/-(?<match>\\d)/ui”, “_$1”, $filename ); if ( rename( … Read more

Auto-modifying original [full size] images

Yes, there is. Found here: http://www.wprecipes.com/how-to-automatically-use-resized-image-instead-of-originals It will replace the original picture with the large size, defined in Media Settings (/wp-admin/options-media.php). Here’s the code: add_filter(‘wp_generate_attachment_metadata’,’replace_uploaded_image’); function replace_uploaded_image($image_data) { // if there is no large image : return if ( !isset($image_data[‘sizes’][‘large’]) ) return $image_data; // paths to the uploaded image and the large image $upload_dir = … Read more

WP 3.5 and Galleries – how to count images?

This works: $images = get_children( array( ‘post_parent’ => $post->ID, ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’, ‘orderby’ => ‘menu_order’, ‘order’ => ‘ASC’, ‘numberposts’ => 999 )); if ( $images ) { $total_images = count( $images ); } The variable $total_images will hold the count of images in your gallery.