Here the whole old code structure. I want to get the last image in gallery and link to the gallery
$galleryid = $gallery->gid;
$gallery = $nggdb->find_gallery($gallery->gid);
$picture_data = $wpdb->get_results("SELECT filename, alttext FROM abcd_ngg_pictures WHERE galleryid=".$galleryid);
$iie = count($picture_data) - 1;
foreach ( $picture_data as $ng_image ) {
if ($ii < $iie ) {
if ($ii == 0) {
$ipath = get_bloginfo('wpurl').str_replace('\\','/',$gallery->path).$ng_image->filename;
?>
<a class="btn item-btn fancybox" href="<?php echo $ipath; ?>" rel="<?php echo $gallery->gid ?>"><?php echo $moretxt; ?></a>
<?php }
else {
$ipath = get_bloginfo('wpurl').str_replace('\\','/',$gallery->path).$ng_image->filename;
echo '<a href="'.$ipath.'" class="fancybox" rel="'. $gallery->gid . '" style="display: none;" /></a>';
}
}
$ii = $ii + 1;
}
This dont work:
$ii = 0;
$gallery_array = array();
$galleryid = $gallery->gid;
$gallery_mapper = \Imagely\NGG\DataMappers\Gallery::get_instance();
$gallery = $gallery_mapper->find($galleryid);
$image_mapper = \Imagely\NGG\DataMappers\Image::get_instance();
$picture_data = $image_mapper->find_all_for_gallery($galleryid, true);
$iie = count($picture_data) - 1;
foreach ( $picture_data as $ng_image ) {
if ($ii < $iie ) {
if ($ii == 0) {
$ipath = get_bloginfo('wpurl').str_replace('\\','/',$gallery->path).$ng_image->filename;
?>
<a class="btn item-btn fancybox" href="<?php echo $ipath; ?>" rel="<?php echo $gallery->gid ?>"><?php echo $moretxt; ?></a>
<?php }
else {
$ipath = get_bloginfo('wpurl').str_replace('\\','/',$gallery->path).$ng_image->filename;
echo '<a href="'.$ipath.'" class="fancybox" rel="'. $gallery->gid . '" style="display: none;" /></a>';
// alt="'.$ng_image->alttext.'"
}
}
$ii = $ii + 1;
}
-
This reply was modified 11 months, 2 weeks ago by ODAK71.