Digital experiences for all disciplines
New Landing › How can we help? › Cardinal › How to change the size of images in the block related articles?
New Landing › How can we help? › Cardinal › How to change the size of images in the block related articles?
- This topic has 8 replies, 2 voices, and was last updated 7 years by David Martin – Support.
-
Posted in: Cardinal
-
December 19, 2016 at 1:48 pm #307151
How can I change the size of the displayed image in the block related articles?
Now, all used images are cropped.
December 19, 2016 at 1:54 pm #307153This reply has been marked as private.December 19, 2016 at 2:51 pm #307177You can tell where I can resize images for this block?
December 19, 2016 at 8:09 pm #307275I do not quite understand why you answer the questions of other users that have been set, and after I ignore my question?
December 21, 2016 at 11:39 am #307564Hi,
PLEASE NOTE: Adding an extra reply to your topic, as per our support policy, will take it back in the queue and take us longer to reply to you. Please refrain for doing this. If you need to add extra info, then please edit your last reply.
Please install and activate the supplied child theme, inside the child theme
functions.php
file paste this./* POST RELATED ARTICLES ================================================== */ if ( ! function_exists( 'sf_post_related_articles' ) ) { function sf_post_related_articles() { $related_articles_class = apply_filters( 'sf_post_related_articles_wrap_class', 'container' ); $related_articles_display_type = apply_filters( 'sf_related_articles_display_type', 'list' ); $related_articles_excerpt_length = apply_filters( 'sf_related_articles_excerpt_length', 20 ); $related_articles_count = apply_filters( 'sf_related_posts_count', 4 ); $related_articles_item_class = apply_filters( 'sf_related_posts_item_class', 'col-sm-3' ); $list_class = 'posts-type-'.$related_articles_display_type; if ($related_articles_display_type == "bold") { $list_class .= ' no-gutters'; } else { $list_class .= ' row'; } global $post; $args = array(); $tags = wp_get_post_tags( $post->ID ); $categories = get_the_category( $post->ID ); if ( ! empty( $tags ) ) { $tag_ids = array(); foreach ( $tags as $individual_tag ) { $tag_ids[] = $individual_tag->term_id; } $args = array( 'tag__in' => $tag_ids, 'post__not_in' => array( $post->ID ), 'posts_per_page' => $related_articles_count, // Number of related posts to display. 'ignore_sticky_posts' => 1 ); } else if ( ! empty( $categories ) ) { $category_ids = array(); foreach ( $categories as $individual_category ) { $category_ids[] = $individual_category->term_id; } $args = array( 'category__in' => $category_ids, 'post__not_in' => array( $post->ID ), 'posts_per_page' => $related_articles_count, // Number of related posts that will be shown. 'orderby' => 'rand' ); } $related_posts_query = new WP_Query( $args ); if ( $related_posts_query->have_posts() ) { echo '<div class="related-wrap">'; echo '<div class="related-articles ' . $related_articles_class . '">'; echo '<div class="title-wrap"><h3 class="spb-heading"><span>' . __( "Related Articles", "swiftframework" ) . '</span></h3></div>'; echo '<div class=" recent-posts '.$list_class.' clearfix">'; while ( $related_posts_query->have_posts() ) : $related_posts_query->the_post(); echo sf_get_recent_post_item( $post, $related_articles_display_type, $related_articles_excerpt_length, $related_articles_item_class ); endwhile; echo '</div>'; echo '</div>'; echo '</div>'; } wp_reset_query(); } add_action( 'sf_post_after_article', 'sf_post_related_articles', 10 ); }
December 26, 2016 at 9:19 am #307993This reply has been marked as private.December 28, 2016 at 12:53 pm #308167Can you add your FTP details?
Thanks.
December 28, 2016 at 1:00 pm #308173This reply has been marked as private.December 28, 2016 at 4:51 pm #308245Ah yes, I see. Please discard the code I provided.
Within your child theme you had this already, which I have modified:
if ( ! function_exists( 'sf_get_recent_post_item' ) ) { function sf_get_recent_post_item( $post, $display_type = "bold", $excerpt_length = 20, $item_class = "" ) { $recent_post = $recent_post_figure = $link_config = $item_icon = ""; $thumb_type = sf_get_post_meta( $post->ID, 'sf_thumbnail_type', true ); $thumb_image = rwmb_meta( 'sf_thumbnail_image', 'type=image&size=full' ); $thumb_video = sf_get_post_meta( $post->ID, 'sf_thumbnail_video_url', true ); $thumb_gallery = rwmb_meta( 'sf_thumbnail_gallery', 'type=image&size=thumb-image' ); foreach ( $thumb_image as $detail_image ) { $thumb_img_url = $detail_image['url']; break; } if ( ! $thumb_image ) { $thumb_image = get_post_thumbnail_id(); $thumb_img_url = wp_get_attachment_url( $thumb_image, 'full' ); } // POST META global $sf_options; $single_author = $sf_options['single_author']; $remove_dates = $sf_options['remove_dates']; $post_author = get_the_author_link(); $post_date = get_the_date(); $post_date_str = get_the_date('Y-m-d'); $item_title = get_the_title(); $post_permalink = get_permalink(); $post_comments = get_comments_number(); $custom_excerpt = sf_get_post_meta( $post->ID, 'sf_custom_excerpt', true ); $post_excerpt = ''; if ( $custom_excerpt != '' ) { $post_excerpt = sf_custom_excerpt( $custom_excerpt, $excerpt_length ); } else { $post_excerpt = sf_excerpt( $excerpt_length ); } // MEDIA CONFIG $thumb_link_type = sf_get_post_meta( $post->ID, 'sf_thumbnail_link_type', true ); $thumb_link_url = sf_get_post_meta( $post->ID, 'sf_thumbnail_link_url', true ); $thumb_lightbox_thumb = rwmb_meta( 'sf_thumbnail_image', 'type=image&size=large' ); $thumb_lightbox_image = rwmb_meta( 'sf_thumbnail_link_image', 'type=image&size=large' ); $thumb_lightbox_video_url = sf_get_post_meta( $post->ID, 'sf_thumbnail_link_video_url', true ); $thumb_lightbox_video_url = sf_get_embed_src( $thumb_lightbox_video_url ); $thumb_lightbox_img_url = wp_get_attachment_url( $thumb_lightbox_image, 'full' ); // LINK CONFIG if ( $thumb_link_type == "link_to_url" ) { $link_config = 'href="' . $thumb_link_url . '" class="link-to-url"'; $item_icon = apply_filters( 'sf_post_link_icon', "ss-link" ); } else if ( $thumb_link_type == "link_to_url_nw" ) { $link_config = 'href="' . $thumb_link_url . '" class="link-to-url" target="_blank"'; $item_icon = apply_filters( 'sf_post_link_icon', "ss-link" ); } else if ( $thumb_link_type == "lightbox_thumb" ) { $link_config = 'href="' . $thumb_img_url . '" class="lightbox" data-rel="ilightbox[posts]"'; $item_icon = apply_filters( 'sf_post_lightbox_icon', "ss-view" ); } else if ( $thumb_link_type == "lightbox_image" ) { $lightbox_image_url = ''; foreach ( $thumb_lightbox_image as $image ) { $lightbox_image_url = $image['full_url']; } $link_config = 'href="' . $lightbox_image_url . '" class="lightbox" data-rel="ilightbox[posts]"'; $item_icon = apply_filters( 'sf_post_lightbox_icon', "ss-view" ); } else if ( $thumb_link_type == "lightbox_video" ) { $link_config = 'data-video="' . $thumb_lightbox_video_url . '" href="#" class="fw-video-link"'; $item_icon = apply_filters( 'sf_post_video_icon', "ss-video" ); } else { $link_config = 'href="' . $post_permalink . '" class="link-to-post"'; $item_icon = apply_filters( 'sf_post_standard_icon', "ss-navigateright" ); } if ( $thumb_type == "none" ) { $recent_post .= '<div itemscope class="recent-post no-thumb ' . $item_class . ' clearfix">'; } else { $recent_post .= '<div itemscope class="recent-post has-thumb ' . $item_class . ' clearfix">'; } $recent_post_figure .= '<div class="figure-wrap">'; $recent_post_figure .= apply_filters( 'sf_before_recent_post_thumb' , ''); $recent_post_figure .= '<figure class="animated-overlay overlay-alt">'; if ( $thumb_type == "video" ) { $video = sf_video_embed( $thumb_video, 400, 225 ); $recent_post_figure .= '<div class="video-thumb">' . $video . '</div>'; } else if ( $thumb_type == "slider" ) { $recent_post_figure .= '<div class="flexslider thumb-slider"><ul class="slides">'; foreach ( $thumb_gallery as $image ) { $alt = $image['alt']; if ( ! $alt ) { $alt = $image['title']; } $recent_post_figure .= "<li><a " . $link_config . "><img src='{$image['url']}' width='{$image['width']}' height='{$image['height']}' alt='{$alt}' /></a></li>"; } $recent_post_figure .= '</ul></div>'; } else { if ( $thumb_img_url == "" && $thumb_type != "none" ) { $thumb_img_url = "default"; } if( is_single() ) { $image = sf_aq_resize( $thumb_img_url, 760, null, false, false ); } else { $image = sf_aq_resize( $thumb_img_url, 420, 315, true, false ); } if ( $image ) { $recent_post_figure .= '<img itemprop="image" src="' . $image[0] . '" width="' . $image[1] . '" height="' . $image[2] . '" alt="' . $item_title . '" />'; $recent_post_figure .= '<a ' . $link_config . '></a>'; $recent_post_figure .= '<div class="figcaption-wrap"></div>'; $recent_post_figure .= '<figcaption><div class="thumb-info thumb-info-alt">'; $recent_post_figure .= '<i class="' . $item_icon . '"></i>'; $recent_post_figure .= '</div></figcaption>'; } } $recent_post_figure .= '</figure>'; $recent_post_figure .= '</div>'; if ( $display_type == "bold" ) { $recent_post .= $recent_post_figure; $recent_post .= '<div class="details-wrap">'; if ( $thumb_type == "none" ) { $recent_post .= '<h2><a href="' . $post_permalink . '">' . $item_title . '</a></h2>'; } else { $recent_post .= '<h3><a href="' . $post_permalink . '">' . $item_title . '</a></h3>'; } $recent_post .= sf_get_post_details($post->ID, true); $recent_post .= '</div>'; } else if ( $display_type == "list" ) { $recent_post .= '<a class="list-post-link" href="' . $post_permalink . '"></a>'; if ( $image ) { $recent_post_figure .= '<figure class="animated-overlay">'; $recent_post_figure .= '<img itemprop="image" src="' . $image[0] . '" width="' . $image[1] . '" height="' . $image[2] . '" alt="' . $item_title . '" />'; $recent_post_figure .= '<a ' . $link_config . '></a>'; $recent_post_figure .= '<div class="figcaption-wrap"></div>'; $recent_post_figure .= '<figcaption><div class="thumb-info thumb-info-alt">'; $recent_post_figure .= '<i class="' . $item_icon . '"></i>'; $recent_post_figure .= '</div></figcaption>'; $recent_post_figure .= '</figure>'; } $recent_post .= '<div class="details-wrap">'; $recent_post .= '<h4>' . $item_title . '</h4>'; $recent_post .= '<div class="post-item-details">'; $recent_post .= '<span class="post-date">' . $post_date . '</span>'; $recent_post .= '</div>'; $recent_post .= '</div>'; } else if ( $display_type == "bright" ) { $recent_post .= '<div class="details-wrap">'; $recent_post .= '<div class="author-avatar">' . get_avatar( get_the_author_meta( 'ID' ), '140' ) . '</div>'; $recent_post .= '<h6 class="post-item-author"><span class="author">' . sprintf( '<a href="%2$s" rel="author" itemprop="author">%1$s</a>', $post_author, get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '</span></h6>'; $recent_post .= '<h2><a href="' . $post_permalink . '">' . $item_title . '</a></h2>'; $recent_post .= '<div class="post-item-details">'; $recent_post .= '<span class="post-date">' . $post_date . '</span>'; $recent_post .= '</div>'; $recent_post .= '</div>'; } else if ( $display_type == "bold" ) { $recent_post .= $recent_post_figure; $recent_post .= '<div class="details-wrap">'; if ( $thumb_type == "none" ) { $recent_post .= '<h2><a href="' . $post_permalink . '">' . $item_title . '</a></h2>'; } else { $recent_post .= '<h3><a href="' . $post_permalink . '">' . $item_title . '</a></h3>'; } $recent_post = sf_get_post_details($post->ID, true); $recent_post .= '</div>'; } else { $recent_post .= $recent_post_figure; $recent_post .= '<div class="details-wrap">'; $recent_post .= '<span class="h5"><a href="' . $post_permalink . '">' . $item_title . '</a></span>'; $recent_post .= sf_get_post_details($post->ID, true); if ( $excerpt_length != "0" && $excerpt_length != "" ) { $recent_post .= '<div class="excerpt">' . $post_excerpt . '</div>'; } if ( sf_theme_opts_name() == "sf_atelier_options" && $display_type == "standard-row" ) { $recent_post .= '<a class="read-more-button" href="' . $post_permalink . '">' . __( "Read more", "swiftframework" ) . '</a>'; } $recent_post .= '</div>'; } $recent_post .= '</div>'; return $recent_post; } }
-
Posted in: Cardinal
You must be logged in and have valid license to reply to this topic.