• Resolved PrepVelvet

    (@prepvelvet)


    Hey I’m using this theme on https://www.prepfocus.in/. I have problem with the carousel. The images don’t fit and transition from one to another post is also buggy.

    How can we use the first image in the post as featured image. In most of the theme it’s there by default. The images get auto-scaled too.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter PrepVelvet

    (@prepvelvet)

    I want the width of carousel to be fixed. Same for all the slides.

    Theme Author eminozlem

    (@eminozlem)

    To use first image rather than featured image you can replace :

    if ( has_post_thumbnail() ) {
                        $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large');
                        echo '<a href="' . $large_image_url[0] . '" class="thumbnail cboxElement" title="' . the_title_attribute('echo=0') . '" >';
                        the_post_thumbnail( 'eo-featurette',array('class' => 'featurette-image img-responsive') );
                        echo '</a>';?>
                    <?php }

    to

    if (preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches)) {
    							//check if an image exists at all
    							$first_thumb = $matches [1] [0];
    							// replace the thumbnail size part to get large image url
    							$source_img_rep	 = preg_replace('/(-\d+x\d+)?\.(\w{3,4})$/','',$first_thumb);
    							$ext = pathinfo($first_thumb, PATHINFO_EXTENSION);
    							$first_source = $source_img_rep . '.' . $ext;
    							echo '<a href="' . $first_source . '" class="thumbnail cboxElement" title="' . the_title_attribute('echo=0') . '" ><img class="img-reponsive" src="'.$first_thumb.'" alt="' . the_title_attribute('echo=0') . '" /></a>';
    				}
    				else if ( has_post_thumbnail() ) {
                        $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large');
                        echo '<a href="' . $large_image_url[0] . '" class="thumbnail cboxElement" title="' . the_title_attribute('echo=0') . '" >';
                        the_post_thumbnail( 'eo-featurette',array('class' => 'featurette-image img-responsive') );
                        echo '</a>';?>
                    <?php }

    Remember to use a child theme. Don’t know what you are looking for in terms of width or height of the carousel, but the carousel is going to get a rework in the next version(bootstrap carousel will be replaced with owlcarousel). Let me know if you’ve further questions, marking as resolved.

    Thread Starter PrepVelvet

    (@prepvelvet)

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Carousel and Featured image’ is closed to new replies.