Skip to main content
Share Your Experience: Take the 2024 Developer Survey
3 votes

Display image title and caption on posts and pages

you are trying to get the image title using get_the_title($image_id), but $image_id is not defined in your function. Instead, you should use the id attribute provided in the shortcode attributes. ...
vijay pancholi's user avatar
3 votes
Accepted

Disable image compression for WebP

It does cover webp as well. From several google pages the default compression was 86. You could also test to confirm by uploading a few with different settings in your functions. This issue on Github ...
rudtek's user avatar
  • 6,121
2 votes

How to "lazy load" post thumbnail

<?php the_post_thumbnail( 'thumbnail', array( 'loading' => 'lazy' ) ); ?>
bezkitu's user avatar
  • 76
2 votes

wp_get_attachment_image with custom size not rendering possible 2x srcset image

It appears the problem was that image size variants were being capped by the max_srcset_image_width property that can be raised with the following: add_filter( 'max_srcset_image_width', '...
James0r's user avatar
  • 91
2 votes

Image alt tag is showing post title instead of Alt Text

You can use _wp_attachment_image_alt like @cjbj shows but I am adding an addition to it for the fall back. $alt_text = get_post_meta($post_image_id, '_wp_attachment_image_alt', true); // ...
msz's user avatar
  • 121
2 votes

Image alt tag is showing post title instead of Alt Text

In the place where you use get_the_title($post_id) you need to get the alt attribute that is stored in the post metadata like this: esc_attr (get_post_meta ($post_id, '_wp_attachment_image_alt', true))...
cjbj's user avatar
  • 14.6k
2 votes
Accepted

Set Featured Image of a post

To set a featured image when creating a post using wp_insert_post(), you can use the set_post_thumbnail() function // Create the post $post_id = wp_insert_post($args); // Check if the post was ...
vijay pancholi's user avatar
1 vote

Add custom text before all image captions in WordPress posts

You can filter the image caption using the wp_get_attachment_caption filter: add_filter( 'wp_get_attachment_caption', 'wpse422651_filter_image_caption', 10, 2 ); /** * Filters the image caption. * ...
Pat J's user avatar
  • 11.9k
1 vote

Blurry Images on my Website

Text on images always look blurry when you view it at any other size than 100%. You can try saving them as an svg and using that, then you have to install a plugin that let's you upload svg's into ...
WordPress Buddha's user avatar
1 vote
Accepted

Media Library Issues

What you need is a way to scan your uploads directory and register any unregistered files. There are plugins that can help with this. One such plugin is "Add From Server". This allows you to ...
ray-happyforms's user avatar
1 vote
Accepted

Image editing no longer works after moving to a new server

As discussed in comments this was because the new site was missing both of the supported image editing tools, GD and ImageMagick, as PHP modules. (Either one will work - you don’t need both.) The '...
Rup's user avatar
  • 4,277
1 vote

Replace image with its alt text?

You should be able to use the the_content filter for this. Something like this... add_filter( 'the_content', 'wpse418925_replace_images_with_alt' ); function wpse418925_replace_images_with_alt( $...
Pat J's user avatar
  • 11.9k
1 vote
Accepted

Get field added via attachment_fields_to_edit filter in Gutenberg

Yes, you're right that the slimImageObject function is the reason why you're seeing/getting only those limited list of props. But don't worry, you can use wp.data.select( 'core' ).getMedia( <...
Sally CJ's user avatar
  • 39.3k
1 vote

WordPress Site Broken and it gives Headers Already sent error

What could be the issue. You unzipped the theme and put its files in the root WordPress folder, overwriting important files and breaking your site. Doing this will always break your site. It only ...
Tom J Nowell's user avatar
  • 59.4k
1 vote

Edit image preview is not displayed

Make sure that not only wp-config.php, and functions.php has no empty lines. In my case it was one of my custom theme files, which was included with include PHP function inside of single.php file. I ...
Sid's user avatar
  • 113
1 vote

Bulk edit WP posts to update embeded images with new alt tags

The situation WordPress stores image/media details as an attachment port type within the database. When you edit an image in the media library, all the details are correctly saved in the database. We ...
Baljka Gan's user avatar
1 vote

Wordpress Media Library showing wrong preview size?

This is less a fix, and more of a hack to possibly achieve what you need. In my case, WP was using the largest possible image size as the preview thumbnail in the Media Library. As noted in other ...
donohoe's user avatar
  • 161

Only top scored, non community-wiki answers of a minimum length are eligible