Custom image size not regenerating when image editted

To regenerate custom image size when image is edited in image editor , You have to add following options in wp_options table using update_option function along with add_image_size. Example : $img_size_name=”custom-size”; // The new image size name. if ( function_exists( ‘add_theme_support’ ) ) add_image_size($img_size_name, 100, 100 , true); update_option($img_size_name.’_size_w’, 100); update_option($img_size_name.’_size_h’, 100); update_option($img_size_name.’_crop’, 1);

Additional image sizes are not being generated

From https://make.wordpress.org/core/2012/12/06/wp_image_editor-is-incoming/ : Imagick support requires Imagick 2.2.0+ compiled against Imagemagick 6.2.9+, for full support. If the required functions aren’t available, WordPress will default back to GD. If you can, create a PHP file somewhere on your server with this content: <?php phpinfo(); ?>. Then load the page and see if there is a section … Read more

Strip Image Classes from HTML Output

Take a closer look at get_image_tag() which can take a lot of parameters like $id, $alt, $title, $align, $size. If you look even closer you’ll find the get_image_tag_class filter to change the image class names (like class, ID, align and size). You can use the filter within your functions.php like this: Note: This will still … Read more

Regenerate thumbnails after upload

Adding $attach_data = wp_generate_attachment_metadata( $attach_id, $filename ); wp_update_attachment_metadata( $attach_id, $attach_data ); after $attach_id = wp_insert_attachment( $attachment, $filename); Fixed it.

How to Optimize images after uploading all images to WordPress Site?

You can optimize uploaded image in wordpress by EWWW Image Optimizer. This plugin giving facility for bulk optimization. So you can compress and optimize image very easily. Also this plugin optimize images according proportion. So optimized image not losing quality. It is very best plugin for image optimization.I am currently using this plugin.

resize from small images to large

Found a solution here that is working: http://www.binarynote.com/how-to-perfectly-upscale-image-in-wordpress.html function binary_thumbnail_upscale( $default, $orig_w, $orig_h, $new_w, $new_h, $crop ) { if ( !$crop ) return null; $aspect_ratio = $orig_w / $orig_h; $size_ratio = max($new_w / $orig_w, $new_h / $orig_h); $crop_w = round($new_w / $size_ratio); $crop_h = round($new_h / $size_ratio); $s_x = floor( ($orig_w – $crop_w) / 2 … Read more

Add custom HTML to posts page

If you want to modify the main <header> output take a look at header.php. This file will be called before the other templates. If you want to modify the template that is used to display your latest blog posts, index.php would be the file of choice. Index.php is also the fallback template for any post … Read more

How to get custom image size for image uploaded in Customizer

Apparently, your mod is storing the complete path to the image as a string. That leaves you little alternative but to do a search and replace on the string: $img = get_theme_mod(‘image-1’); if (!empty ($img)) { $img = preg_replace (‘.(jpg|jpeg|png|gif)$’,’-525×350$0′); if (!file_exists($img)) $img = get_template_directory_uri().’/images/default.jpg’; } else if (!file_exists($img)) $img = get_template_directory_uri().’/images/default.jpg’; In words. Get … Read more