add alt text to images loaded from json with media_sideload_image

Once you have the attachment ID you can add alt text by setting the _wp_attachment_image_alt post meta for the attachment: update_post_meta( $attachment_id, ‘_wp_attachment_image_alt’, ‘Alt text here’ ); To get the attachment ID from media_sideload_image() you can set the 4th argument to ‘id’: $attachment_id = media_sideload_image( $file, $post_id, $desc, ‘id’ ); if ( ! is_wp_error( $attachment_id … Read more

How can I add image sizes for a specific custom post type?

You can try this (not tested): // Add image sizes for book outside add_image_size( ‘book_portrait_thumbnail’, ‘150’, ‘215’, true ); add_image_size( ‘book_portrait_square’, ‘300’, ‘300’, true ); // Delete all intermediate image sizes add_filter( ‘intermediate_image_sizes’, ‘custom_image_sizes’, 99 ); function custom_image_sizes( $image_sizes ) { //In case of book return book sizes array if( isset($_REQUEST[‘post_id’]) && ‘books’ === get_post_type( … Read more

Jetpack Lazy load images fade in

Which part doesn’t work? You might need to change your transition property to include a name, as well as a delay. Optionally add the timing: .jetpack-lazy-image { opacity: 0; transition: opacity 0.3s ease; } https://developer.mozilla.org/en-US/docs/Web/CSS/transition

Redirect when user clicks on an image

You have 2 ids with the same name and the form gets broken, always provide different ids on a page: <form method=’post’ id=’back_button_form’ action=”> <p class=”form-submit”> <input name=”back_button_img” type=”image” id=’back_button_img’ src=”https://wordpress.stackexchange.com/questions/345310/back.png”/> </p> </form>

Enlarge Featured WordPress Images

There is a plugin called Bulk Resize Media that might be able to do this for you, but I am not sure I would recommend doing that. Bulk resizing images to a SMALLER size is hardly ever a problem. Images are easily compressed without degradation. They are compressed by removing every Nth pixel, which the … Read more

How to change background image

This code isn’t coming from Core, so you should search down where the shortcode comes from – a theme or a plugin. My guess is that “2407” might be the Post ID of a particular image. If that is true, then you can go into your Media Library and find the Post ID of the … Read more