Problem with slider if it only contains few images
-
Hi David,
Thank you for a great plugin!
You’ve assisted me earlier with a PHP code to show sliders in an archive based on images from ACF. This works fine with most of our posts as we have many images in our posts. However, we have one post with only 3 images, and for some reason the slider only shows 2 images when loaded. The 3rd is visible after sliding, but it only shows 2 images at the time (for other posts it shows 3-4 images at the same time based on screen width).
Do you have any idea why this would happen? It shows all 3 images if I set center_selected_slide=”true” , but I need this to be false to avoid post with 3 images to be centered.
Below is the code you helped with earlier:
$postid = get_the_ID();
$postlink = get_permalink();
echo ‘‘;
// If at least 1 image is present in the Project Images Gallery field
if( $images = get_field(‘bilder’) ) {
$image_ids = wp_list_pluck( $images, ‘url’ );
//$resizedImage = fImg::resize( ‘. $resizedImage . ‘, 600, 400, false ); // width, height, false = maintain aspect ration, true = crop
// Use thumbnails, only if we have more than 1 image
$use_thumbnails = ( 1 < count( $image_ids ) ? true : false ); // Show slider echo ‘‘;
$slider = ‘[sliderpro id=”‘ . $postid . ‘” width=”600″ height=”400″ visible_size=”2600″ arrows=”true” autoPlay=”false” auto_thumbnail_images=”‘ . $use_thumbnails . ‘” lazy_loading=”true” loop=”true” center_selected_slide=”false” allow_cache=”true”]’;
foreach($image_ids as $image_id) {
$slider .= ‘[sliderpro_slide] [sliderpro_slide_element name=”main_image_source”]’ . $image_id . ‘[/sliderpro_slide_element][sliderpro_slide_element name=”main_image_link”]’ . $postlink. ‘[/sliderpro_slide_element][/sliderpro_slide]’;
}$slider .= ‘[/sliderpro]
‘;
echo do_shortcode($slider);
echo ”;
}
Thank you,
Lars
- The topic ‘Problem with slider if it only contains few images’ is closed to new replies.