Search the Community
Showing results for tags 'image slider'.
-
Get Image by number, but if loop when no image? Help
Rowena_Harris posted a topic in PHP Coding Help
Hi - can anyone help? I'm new to PHP land, and failing at this particular part. I have an image slider - where each image is contained in a div (e.g it is not a slider using ul and il...) It is will be used in a template for many pages, which will each have a varying number of images. There for I need to create a loop that say 'when there is no img url found, return to img 1' I'm stump. Currently this is beyond me ..... Or do I need to start from scratch? (ARGH!) Here is my function function getImage($num) { global $more; $more = 1; $link = get_permalink(); $content = get_the_content(); $count = substr_count($content, '<img'); $start = 0; for($i=1;$i<=$count;$i++) { $imgBeg = strpos($content, '<img', $start); $post = substr($content, $imgBeg); $imgEnd = strpos($post, '>'); $postOutput = substr($post, 0, $imgEnd+1); $postOutput = preg_replace('/width="([0-9]*)" height="([0-9]*)"/', '',$postOutput);; $image[$i] = $postOutput; $start=$imgBeg+$imgEnd+1; } if(stristr($image[$num],'<img')) { echo '<a href="'.$link.'">'.$image[$num]."</a>"; } $more = 0; } and here's how I use it in the html: <div class="project-slider-mask w-slider-mask"> <div class="w-slide"> <?php getImage('1'); ?> </div> <div class="w-slide"> <?php getImage('2'); ?> </div> <div class="w-slide"> <?php getImage('3'); ?> </div> <div class="w-slide"> <?php getImage('4'); ?> </div> etc etc etc Help much much appreciated....been failing at this for so long!- 2 replies
-
- get image
- image slider
-
(and 1 more)
Tagged with:
-
Hello, I am using this theme on a site build. I would like to replace the static header image with the Slidedeck 2 Pro, image slider. Their code provided for placing into the header is below. <?php echo do_shortcode( '[SlideDeck2 id=XXXX iframe=1]' ); ?> The pertinent part of my theme's header code is as follows: <div id="header-wrapper"> <div id="header"> <div class="container"> <a href="<?php bloginfo('url'); ?>"><?php $logo = (get_option('myproduct_logo') <> '') ? get_option('myproduct_logo') : get_bloginfo('template_directory').'/images/top-bg.jpg'; ?> <img src="<?php echo esc_url($logo); ?>" alt="<?php echo esc_attr(get_bloginfo('name')); ?>" id="logo"/></a> I have also attached the complete header file. header.php Any help on this would be greatly appreciated, as I am a noob, and do not have the knowledge to perform this task. Thank You, Paul