Rename media files generated during upload

Using my own code from here, i updated the logic to add the name of the image size instead of the suffix, try adding this to your functions.php file: add_filter(“wp_image_editors”, “my_wp_image_editors”); function my_wp_image_editors($editors) { array_unshift($editors, “WP_Image_Editor_Custom”); return $editors; } // Include the existing classes first in order to extend them. require_once ABSPATH . WPINC . … Read more

How to get full absolute url for post attachment?

esc_attr() might not be necessary on the url retrieved by wp_get_attachment_image_src. I have referred to a code example from the WordPress Codex page on wp_get_attachment_image_src and adapted the following code that works for me. global $post; $thumbnailSrc = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), ‘medium’); if ( $thumbnailSrc ) : echo ‘<meta property=”og:image” content=”‘.$thumbnailSrc[0].'”>’; endif; Edit: Since you are using … Read more

Local WordPress installation doesn’t crop images

For the record since I ended up here when experiencing the same issue on my localhost: In php.ini, Uncomment the line with: extension=php_gd2.dll Restart apache / all services This sorted it out for me (I may have switched a few other services on while I was there, but I believe this is what fixed it!)

ACF Plugin – Random Gallery Image with wp_get_attachment_image()

<?php $images = get_field(‘gallery’); $size=”full”; // (thumbnail, medium, large, full or custom size) $rand = array_rand($images, 1); if( $images ): ?> <?php echo wp_get_attachment_image( $images[$rand][‘ID’], $size ); ?> <?php endif; ?> This code should work. array_rand() return key if second param set to 1 or array with keys if second param > 1