Closed David-Streck closed 10 years ago
I didn't see anything in the documentation.
I've tried adding array('class' => 'alignleft') like you would when normally adding a class to a featured image but it breaks it. Here is an example of what I tried: <?php if (class_exists('MultiPostThumbnails')) : MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'secondary-image', array('class' => 'alignleft')); endif; ?>
Any thoughts on how this can be done?
Great plugin btw. Thanks for sharing :)
@chrisscott is this the right place for this kind of thing? Any thoughts on how I can add a class would be greatly appreciated.
Take a look at the function signature for MultiPostThumbnails::the_post_thumbnail()
:
function the_post_thumbnail($post_type, $id, $post_id = null, $size = 'post-thumbnail', $attr = '', $link_to_original = false)
The array of attr with the class should be passed in as the 5th arg, not 3rd like your sample code. So, your code should probably look something like:
MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'secondary-image', null, 'post-thumbnail', array('class' => 'alignleft'))
@chrisscott Thanks! That works!!! :)
<?php if (class_exists('MultiPostThumbnails')) : MultiPostThumbnails::the_post_thumbnail( get_post_type(), 'secondary-image', null, 'post-thumbnail', array('class' => 'img-fluid')); endif; ?>
Thanks! That works!!! :)
Can you clarify is you're asking how this is done or reporting a bug? A code sample would be helpful if you're trying something and it isn't working.