How to add css class to a specific set of images?

You can use the get_image_tag_class filter which passes the attachment ID as an argument: apply_filters(‘get_image_tag_class’, string $class, int $id, string $align, string|array $size) So you can use: function my_image_tag_class($class, $id, $align, $size) { // Logic to check your attachment IDs if($some_logic) { $class .= ‘ no-lazy-loaded’; } return $class; } add_filter(‘get_image_tag_class’,’my_image_tag_class’); If you have an … Read more

Change post featured image on hover

You can add a custom field to you team page, call it “second_picture”, or whatever you want, and add the code <div class=”box”> <div class=”rounded-circle” style=”background-image:url(‘<?php the_post_thumbnail_url(‘full’); ?>’)” id=”staff-pic”> <div class=”second-picture” style=”background-image:url(<?php the_field(‘second_picture’); ?>)”></div> </div> <h3 class=”team-name”><?php the_title(); ?></h3> <p class=”description text-center”><?php echo get_the_content(); ?></p> <div class=”social”><a href=”#”><i class=”fab fa-facebook”></i></a><a href=”#”><i class=”fab fa-twitter”></i></a><a href=”#”><i class=”fab … Read more

How to add image id class?

Shamelessly copied from here: https://letswp.io/add-attachment-id-to-the-class-of-wordpress-images/ add_filter( ‘wp_get_attachment_image_attributes’, ‘add_image_id_class’, 10, 2 ); function add_image_id_class( $attr, $attachment ) { $class_attr = isset( $attr[‘class’] ) ? $attr[‘class’] : ”; $has_class = preg_match( ‘/wpimage\_[0-9]+/’, $class_attr, $matches ); if ( !$has_class ) { $class_attr .= sprintf( ‘ wpimage_%d’, $attachment->ID ); $attr[‘class’] = ltrim( $class_attr ); } return $attr; } This … Read more

Restrict Image Uploads to a Certain File Type

First off, PNGs do not necessarily slow your site down anymore than a JPG. It all depends on how the image is saved or optimized and the file size. Anyway. You have a couple options. Since this site is about coding and we don’t support 3rd party plugins I will give you this first. You … Read more

Add instructions to featured image

WordPress has a hook for that. Here is a sample code: function featured_image_dimensions( $content, $post_id, $thumbnail_id ){ $help_text=”<p>” . __( ‘recommended dimensions – H980px by W450px’, ‘my_domain’ ) . ‘</p>’; return $help_text . $content; } add_filter( ‘admin_post_thumbnail_html’, ‘featured_image_dimensions’, 10, 3 ); Add this code to your functions.php and you should be good to go.