Keep image EXIF info after compressing original image?

The problem is that you are using functions from GD library to manipulate images, not functions from WordPress Image API (WP_Image_Editor class). So, WordPress things doesn’t apply to the generated image by your code. WordPress Image API uses ImageMagick if available, otherwise it uses GD library. In order to keep EXIF data: If GD library … Read more

Recent posts with featured image or fallback image with permalink

Here’s the relevant part of your code that should work: // This will make a URL like http://yoursite.com/path/to/fallback.png $fallback_image = site_url( ‘/path/to/fallback.png’ ); $fallback_image = “<img src=”https://wordpress.stackexchange.com/questions/224740/{$fallback_image}” />”; foreach( $recent_posts as $recent ){ echo ‘<div class=”sidebar-entries”>’; $featured_image = get_the_post_thumbnail( $recent[‘ID’], ‘sidebar-thumb’, array( ‘class’ => ‘sidebar-image’ ) ); if ( ! strlen( $featured_image ) ) { … Read more

How to stop images from being wrapped in tags?

this is a function, that unwraps images from p tags inside the_content /** * WP: Unwrap images from <p> tag * @param $content * @return mixed */ function so226099_filter_p_tags_on_images( $content ) { $content = preg_replace(‘/<p>\\s*?(<a .*?><img.*?><\\/a>|<img.*?>)?\\s*<\\/p>/s’, ‘\1’, $content); return $content; } add_filter(‘the_content’, ‘so226099_filter_p_tags_on_images’);

How to add an image from web-link?

This is some specific shortcode to some plugin, that if you just want to paste an image in wordpress editor isn’t necessary. (Also there is not enough info about what this shortcode is about). So there is simple HTML that will simply display link you want as an image, following: <img src=”http://here-goes-some-url-of-your-image” /> Make sure … Read more

Cannot display or echo alt text on featured image

I am not so sure of what I am going to say, but from a fast look, $featured_image is an array (URL, width, height, is_intermediate). so assuming that your alternative text exists in this array, you need to specify its index like this: $featured_image[index_of_alt_text] according to my understanding, the $featured_image array doesn’t contain your alternative … Read more