admin管理员组文章数量:1327824
I need to insert an additional class in php to the image of this post block:
global $excerpt_length;
$bk_length = $excerpt_length;
$excerpt_length = 30;
$this->start_col( 'pbs-col-lg col__md-2_3 mb__xs-2 mb__md-0' );
$settings['thumb_size'] = empty( $settings['thumb_size'] ) ? 'medium_large' : $settings['thumb_size'];
$settings['title_class'] = 'xs__h4 sm__h3 md__h3';
Plugin::get_template('template_wide', $settings, $misc );
$excerpt_length = $bk_length;
// Begin related by tag
if( !empty( $settings['excerpt'] ) && !empty( $misc['ids'] ) ){
global $post;
$backup_post = $post;
if( !empty( $post )){
$post_id = $post->ID;
$tags = wp_get_post_tags( $post_id );
if ( $tags ){
$tag_ids = array();
foreach( $tags as $tag ){
$tag_ids[] = $tag->term_id;
}
$args = array(
'tag__in' => $tag_ids,
'post__not_in' => (array) $misc['ids'],
'posts_per_page' => 3,
'ignore_sticky_posts' => true,
'suppress_filters' => false
);
$related_posts = get_posts( $args );
if( !empty( $related_posts ) ){
echo '<ul class="pbs-related">';
foreach ( $related_posts as $post ) :
setup_postdata( $post );
// Plugin::get_template('template_text_list',);
?>
<li>
<?php the_title( wp_sprintf( '<a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a>' ); ?>
</li>
<?php
if( !empty( $post->ID ) && !in_array( $post->ID, $GLOBALS['wp_post_blocks_listed_posts']) )
$GLOBALS['wp_post_blocks_listed_posts'][] = $post->ID;
endforeach;
echo '</ul>';
}
wp_reset_postdata();
}
}
$post = $backup_post;
}
If I replace this:
$settings['thumb_size'] = empty( $settings['thumb_size'] ) ? 'medium_large' : $settings['thumb_size'];
with this:
$settings['thumb_size'] = empty( $settings['thumb_size'] ) ? 'medium_large nolazyload' : $settings['thumb_size'];
This is printed:
class="attachment-medium_large nolazyload size-medium_large nolazyload wp-post-image"
And the image is displayed in "full" instead of "medium_large".
I need to add a class in php (no jQuery) like something like this class="attachment-medium_large size-medium_large wp-post-image nolazyload"
Thanks guys
本文标签: Add class to image in php
版权声明:本文标题:Add class to image in php 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742222304a2435521.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论