Link to home
Start Free TrialLog in
Avatar of xanabobana
xanabobanaFlag for United States of America

asked on

stretch the arrows to fit?

The arrows look great but I can't figure out how to get the div to stretch when there are only a few images.  here's an example: http://www.creativemusicphotography.com/?p=96

and the code:

      /**
      * start output
      */
      $output = "<!-- begin simple scrollbar gallery -->\n      <div class='gallery' align='center' style='position:relative; z-index:1;'>\n";

      /**
      * first big image
      */
      $output .= "      ".wp_get_attachment_image(key($attachments),"large")."\n";

      /**
      * thumbnails
      */
      $output .= "      <div class='gallery-list'><div style='position:absolute;z-index:100;left:0px;margin-left:-10%;top:340px;width:116%;height:100px;background-color:transparent;'><img src='http://www.creativemusicphotography.com/wp-content/themes/f8-lite/images/left_purple_arrow.jpg' align='left'><img src='http://www.creativemusicphotography.com/wp-content/themes/f8-lite/images/right_purple_arrow.jpg' align='right'></div><br>\n";
      foreach ( $attachments as $id => $attachment ) {
            $big_image = wp_get_attachment_image_src($id, 'large'); // url of big image
//            $thumbnail_image = wp_get_attachment_image_src($id,"thumbnail"); // url of thumbnail
            $output .= "            <a href=\"".$big_image[0]."\">\n";
            $output .= "                        ".wp_get_attachment_image($id,"thumbnail")."\n";
            $output .= "            </a>\n";
      }
      $output .= "      </div></div>\n";

      /**
      * end output
      */
      $output .= "<!-- end simple scrollbar gallery -->\n";
Avatar of Swafnil
Swafnil
Flag of Germany image

Sorry to ask but what exactly do you want to accomplish? Do you want the previous/next arrows to expand to fill the entire view port when the photo is smaller (which I would not recommend because this would look awful) or do you want the middle image (the one of the musician) to expand if it's smaller?

OT: is creativemusicphotography.com your website? If yes, I would recommend to make the header image (and navigation) a lot smaller, otherwise your visitors always have to scroll before seeing the actual content.
Avatar of xanabobana

ASKER

it's not my website, a client with very specific ideas.  she made the header image a while back and will not budge about it.  She wants the purple arrows on either side of the thumbnails, so people know to scroll, but I can't get the div containing the arrows to expand/contract depending on how many thumbnails there are.  
The problem is caused through the oversized div holding the arrows, it's created and positioned before the thumbnail gallery is created. The best way to have the arrows right next to the thumbnails would be to first add the left arrow to a div, then adding all thumbnails followed by the right arrow and then closing the div:

Sorry, I couldn't check the code because I don't have a running WP installation, but I hope you'll get the idea.
$output .= "      <div class='gallery-list' style=\"width:100%;\" align=\"center\">\n".
	"<img src='http://www.creativemusicphotography.com/wp-content/themes/f8-lite/images/left_purple_arrow.jpg' align='left'>\n";
  foreach ( $attachments as $id => $attachment ) {
		$big_image = wp_get_attachment_image_src($id, 'large'); // url of big image
//            $thumbnail_image = wp_get_attachment_image_src($id,"thumbnail"); // url of thumbnail
		$output .= "            <a href=\"".$big_image[0]."\">\n";
		$output .= "                        ".wp_get_attachment_image($id,"thumbnail")."\n";
		$output .= "            </a>\n";
  }
  $output .= "<img src='http://www.creativemusicphotography.com/wp-content/themes/f8-lite/images/right_purple_arrow.jpg' align='right'>\n".
  	"      </div>\n";

Open in new window

that puts the arrows at the very end of the div, and the overflow is hidden.  so if you have a bunch of photos & need to scroll you don't see the arrow until you're done scrolling.  how do I keep the arrows at a fixed point (either end of the stretchable div) & only scroll the thumbs?

i just tried making the arrows into a background image that would stretch with the width of the div (I don't mind if the arrows get a bit distorted)...but never got it to show over the thumbs.  I've attached the entire page of code w/ the css.
simple-scrollbar-gallery.php
I ended up taking count($attachments) and multiplying that by 18 to get the width percentage of the div:

$divwidth=100;
      $numthumbs =count($attachments);
      if ($numthumbs<6) $divwidth=18*$numthumbs;

more than 6 pics, the width could be 100%
There is still a problem if there are more than 6 images displayed, the 7th picture of the series will overlap the right scroll arrow and the arrows will scroll along with the images. How about removing the arrows and adding a note below the gallery like "Move mouse left/right to scroll"? The scrolling gallery itself looks quite nice.
ASKER CERTIFIED SOLUTION
Avatar of Swafnil
Swafnil
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
yes, looks great- thanks!
great, so helpful!
Good morning,

great you like it! I just saw a minor issue with the code, I forgot to add a "%" after the:

width:{$divwidth}

so it should read

width:{divwidth}%

Adding the percentage sign should put the arrows right next to the images instead of having them at the left- and rightmost positions.