How to get title of images in post content

just change the $post->ID with get_post_thumbnail_id(), and possibly we can delete also the global $post; if( ! ( function_exists( ‘add_alt_image_content’ ) ) ) { function add_alt_image_content( $content ) { if ( is_single() && in_the_loop() && is_main_query() ) { global $post; $image = get_post(get_post_thumbnail_id()); $image_title = $image->post_title; $pattern = ‘~(<img.*? alt=”)(“[^>]*>)~i’; $replace=”$1”.$image_title.’$2′; $content = preg_replace( $pattern, … Read more

Custom image size with srcset

Have a look at this answer: https://wordpress.stackexchange.com/a/243284/64435 If you do not create multiple versions of same proportions no data-src-set will be loaded since you have only one possible target

Resize post thumbnail

Why don’t you use this add_image_size( ‘custom-thumbnail’, 300, 300, true ); in funtions.php and call it <img src=”<?php echo get_the_post_thumbnail_url(‘custom-thumbnail’); ?>”> in your page?

Rebuilding core image block

I discovered that I used master branch of github where I took core/image block source. Obviously, useBlockProps is yet not part of the core (or not implemented in @wordpress/create-blocks webpack setup). After switching to wordpress 5.5 Gutenberg branch version of image block, everything was fine.