Add class to featured_image output
-
Hello,
I’d like to add a “img-responsive” class to the html output by the qw_theme_featured_image function in includes/fields/featured_image.inc file.
I can do this by altering the file itself (see below) but I’m pretty sure this isn’t great practice as the code will just be overwritten when the plugin upgrades.
What is the best practice way to achieve this?
Original qw_theme_featured_image function:
function qw_theme_featured_image($post, $field) { $style = $field['image_display_style']; if (has_post_thumbnail($post->ID)) { $image_id = get_post_thumbnail_id($post->ID, $style); return wp_get_attachment_image( $image_id, $style ); } }
My altered version:
function qw_theme_featured_image($post, $field) { $style = $field['image_display_style']; if (has_post_thumbnail($post->ID)) { $image_id = get_post_thumbnail_id($post->ID, $style); return wp_get_attachment_image( $image_id, $style, false, array( 'class' => 'img-responsive' ) ); } }
Thanks,
Ed
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Add class to featured_image output’ is closed to new replies.