Image Scaling using get_the_post_thumbnail issue in WordPress

ALWAYS REGENERATE SOURCE SET ON IMAGE EDIT (New material, especially the custom function, follows conversation in comment thread.) The following function automatically regenerates a full source set after an image edit action. /** * ALWAYS REGENERATE FULL SOURCE SET AFTER EDITING IMAGE * answering StackExchange WordPress Development Question * see: https://wordpress.stackexchange.com/questions/288581/image-scaling-using-get-the-post-thumbnail-issue-in-wordpress/ * exploits code already … Read more

wp_get_attachment_image_src problem

Try using the Regenerate Thumbnails plugin, that will run through all your media and regenerate thumbnails according to the registered image sizes. Also note that that you’re getting the hight parameter as 226 because during add_image_size your third parameter said to not crop the image. Change that to true if you need cropping.

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

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.

Change WordPress image URLs via filter

You will most likely want to use filters. The main issue is that developers will need to make sure to use the correct functions like “the_post_thumbnail()” etc. You can use wp_get_attachment_url https://codex.wordpress.org/Function_Reference/wp_get_attachment_url I use this when doing local development, but want all my local images to load from the Production server as I don’t have … Read more

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