xanabobana
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($attac hments),"l arge")."\n ";
/**
* thumbnails
*/
$output .= " <div class='gallery-list'><div style='position:absolute;z -index:100 ;left:0px; margin-lef t:-10%;top :340px;wid th:116%;he ight:100px ;backgroun d-color:tr ansparent; '><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_sr c($id, 'large'); // url of big image
// $thumbnail_image = wp_get_attachment_image_sr c($id,"thu mbnail"); // url of thumbnail
$output .= " <a href=\"".$big_image[0]."\" >\n";
$output .= " ".wp_get_attachment_image( $id,"thumb nail")."\n ";
$output .= " </a>\n";
}
$output .= " </div></div>\n";
/**
* end output
*/
$output .= "<!-- end simple scrollbar gallery -->\n";
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(
/**
* thumbnails
*/
$output .= " <div class='gallery-list'><div style='position:absolute;z
foreach ( $attachments as $id => $attachment ) {
$big_image = wp_get_attachment_image_sr
// $thumbnail_image = wp_get_attachment_image_sr
$output .= " <a href=\"".$big_image[0]."\"
$output .= " ".wp_get_attachment_image(
$output .= " </a>\n";
}
$output .= " </div></div>\n";
/**
* end output
*/
$output .= "<!-- end simple scrollbar gallery -->\n";
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.
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";
ASKER
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 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
ASKER
any ideas? this is the old question if that helps.
https://www.experts-exchange.com/questions/26449419/How-do-I-add-arrows-to-simple-scrollbar-gallery-wordpress-plugin.html
https://www.experts-exchange.com/questions/26449419/How-do-I-add-arrows-to-simple-scrollbar-gallery-wordpress-plugin.html
ASKER
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%
$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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
yes, looks great- thanks!
ASKER
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.
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.
OT: is creativemusicphotography.c