Use Gravatar as fallback image if no local image is not found

You can use the get_avatar_url filter (see the arguments passed here in the source code) to change the avatar url and then simply use get_avatar() with the user email in the theme as you’re used to. add_filter(‘get_avatar_url’, ‘wpse_avatar_or_gravatar’, 10, 3); function wpse_avatar_or_gravatar($url, $id_or_email, $args) { // was id passed via $id_or_email if ($id_or_email == intval($id_or_email)) … Read more

Get full URL of images in media library including http://

I’m sure some plugin or your theme modifies your attachment url. Try to find wp_get_attachment_url hook in your code or simply create your own with high priority this way: add_filter(‘wp_get_attachment_url’, function($url) { return preg_replace(“~^//(.+)$~”, “https://$1”, $url); }, 999); or better: add_filter(‘wp_get_attachment_url’, function($url) { return set_url_scheme($url, ‘https’); }, 999); But I recommend you to find the … Read more

Question about add_image_size()

First, let’s check the behavior of cropping. According to code reference: If false (default), images will be scaled, not cropped. If an array in the form of array( x_crop_position, y_crop_position ): x_crop_position accepts left, center, or right. y_crop_position accepts top, center, or bottom. Images will be cropped to the specified dimensions within the defined crop … Read more

The the post id from image id

The featured image is stored as post meta with the key _thumbnail_id, so you could use a meta query to get posts with a specific thumbnail: $posts = new WP_Query( array( ‘meta_query’ => array( array( ‘key’ => ‘_thumbnail_id’, ‘value’ => $attachment_id, ), ), ) ); Where $attachment_id is the ID of the image.

Show featured image option not in screen options

The “All Posts” page – /wp-admin/edit.php – does not show a featured image just by using WP Core. You have to add code to display featured images there. You may need to look back at your backups to see what code you were previously using to get the featured image to show up. It could … Read more