Wpig Image gallery change help
-
Just found the wpig https://www.thepenguinmafia.com/projects/wpig image gallery and it’s brilliant. Simple, clean, easy to use, built in uploading and gallery management.
Need one small bit of help. I’m no php programmer but I can get by customising scripts normally. I’m trying to change the image display on pages from tables to divs. The section is lines 274 – 314 and I’ve changed the code from this:
//wpig_show_gallery() displays the gallery on the page, if the tag is set to do so.
function wpig_show_gallery($content) {
global $wpdb;
$siteurl = get_option('siteurl');
$gallery = '<table border=0><tr><th>Image Preview</th><th>Title & Description</th>';
if(preg_match('|[gallery:([0-9]+)]|', $content, $matches) > 0) {
$galleryid = $matches[1];
$num_results = $wpdb->query("SELECT title, imgdesc, imgpath FROM wp_imagegallery WHERE imggallery=$galleryid ORDER BY id");
$i = 0;
while($i < $num_results) {
$row = $wpdb->get_row("SELECT title, imgdesc, imgpath FROM wp_imagegallery WHERE imggallery=$galleryid ORDER BY id", ARRAY_A, $i);
if(!file_exists(get_option('wpig_path') . 'gallery/thumbcache/' . $row['imgpath'])) {
$srcim = @imagecreatefromjpeg($siteurl . '/wp-content/gallery/' . $row['imgpath']);
$newwidth = 100;
$newheight = 100 * (imagesy($srcim)/imagesx($srcim));
$dstim = @imagecreatetruecolor($newwidth, $newheight);
imagecopyresized($dstim, $srcim, 0, 0, 0, 0, $newwidth, $newheight, imagesx($srcim), imagesy($srcim));
imagejpeg($dstim, get_option('wpig_path') . 'gallery/thumbcache/' . $row['imgpath']);
}
$gallery .= '<tr><td><a href="' . $siteurl . '/wp-content/gallery/' . $row['imgpath'] . '"><img src="' . $siteurl . '/wp-content/gallery/thumbcache/' . $row['imgpath'] . '" border=0></a></td><td><strong>' . $row['title'] . '</strong>' . $row['imgdesc'] . '</td></tr>';
$i++;
}
$gallery .= '</table>';
return preg_replace('|[gallery:([0-9]+)]|', $gallery, $content);
} else {
return $content;
}
}
to this:
//wpig_show_gallery() displays the gallery on the page, if the tag is set to do so.
function wpig_show_gallery($content) {
global $wpdb;
$siteurl = get_option('siteurl');
if(preg_match('|[gallery:([0-9]+)]|', $content, $matches) > 0) {
$galleryid = $matches[1];
$num_results = $wpdb->query("SELECT title, imgdesc, imgpath FROM wp_imagegallery WHERE imggallery=$galleryid ORDER BY id");
$i = 0;
while($i < $num_results) {
$row = $wpdb->get_row("SELECT title, imgdesc, imgpath FROM wp_imagegallery WHERE imggallery=$galleryid ORDER BY id", ARRAY_A, $i);
if(!file_exists(get_option('wpig_path') . 'gallery/thumbcache/' . $row['imgpath'])) {
$srcim = @imagecreatefromjpeg($siteurl . '/wp-content/gallery/' . $row['imgpath']);
$newwidth = 100;
$newheight = 100 * (imagesy($srcim)/imagesx($srcim));
$dstim = @imagecreatetruecolor($newwidth, $newheight);
imagecopyresized($dstim, $srcim, 0, 0, 0, 0, $newwidth, $newheight, imagesx($srcim), imagesy($srcim));
imagejpeg($dstim, get_option('wpig_path') . 'gallery/thumbcache/' . $row['imgpath']);
}
$gallery = '<div class=imgtbl><a href="' . $siteurl . '/wp-content/gallery/' . $row['imgpath'] . '"><img src="' . $siteurl . '/wp-content/gallery/thumbcache/' . $row['imgpath'] . '" border=0></a>' . $row['title'] . '' . $row['imgdesc'] . '</div>';
$i++;
}
return preg_replace('|[gallery:([0-9]+)]|', $gallery, $content);
} else {
return $content;
}
}
but it’s only showing the last image/title/description from the gallery.
Any ideas?
- The topic ‘Wpig Image gallery change help’ is closed to new replies.