Project:IMCE_Gallery
Version:5.x-1.x-dev
Component:Code
Category:support request
Priority:critical
Assigned:edwardlee
Status:active

Issue Summary

i have installed IMCE and IMCE gallery, and i try to create a gallery and upload photo using "personal files".

After uploaded, so i add it into my gallery but i click on the gallery i created, the photo display is just nothing while i point my mouse on it i can see this "http://www.mydomain.com/?# i think this url is couse the pic not showing properly.

2nd thing is when i point my mouse "back to gallery" it show me "http://user/1/imce_gallery" may i know what's wrong with it?

Please help

Comments

#1

I have the same problem. Just placeholders instead of images.

#2

Same problem, but the photos display if it is my own gallery, but if someone else is looking then the same error as above.

#3

qucik hack:

change the function theme_gallery_items to:

function theme_gallery_items($rows) {
global $base_path;
$userid = arg(1);

$output = '';

$img_num=0;
$a = 0;
foreach($rows as $filename) {
$path = 'files' . '/u' . $userid . '/' . $filename;

jim

#4

Title:error display photos» error display photos - fixed!

Thanks for your post Jim, it didn't quite work for me at first (I know next to nothing about php!) but after a little tweaking I think I got it right. This is what I did and it fixed the problems I was having, hope it helps someone cos this drove me pretty crazy!

I am running Drupal 5, with the IMCE (5.x-1.0) and IMCE_Gallery (5.x-1.x-dev) module installed. I then changed the amount of galleries a user can create to 3(default was zero?) in IMCE Gallery Settings, other than that the rest was all left with the default settings.

The main problems I had was that when I went into a user's gallery, no images would display. The stylesheet seemed to load but the images wern't there even though I had definitely uploaded some images to that gallery.

Here's what I did to fix this:

My original function function theme_gallery_items in modules/imce_gallery/imce_gallery.module file looked like this (starts at line 359):

<?php
function theme_gallery_items($rows, $folder) {
        global
$base_path;
       
$output = '';

       
$img_num=0;
       
$a = 0;
        foreach(
$rows as $filename) {
              
$path = $folder . '/' . $filename;
               
$attributes = array("width" => '110', 'border' => '1', 'id' => 'img_'.$img_num, 'name' => 'gallery_images');
               
$img = theme('image', $path, '', '', $attributes, 0);
               
$link_attributes = array('onClick' => 'get_orig("'.$base_path.$path.'", '.$img_num.');return false;');
               
$img_array[$a] = l($img, '', $link_attributes, '', '', '', 1);
               
$a++;
                if(
$a >= 5) {
                       
$rows_img[] = $img_array;
                       
$img_array = array();
                       
$a = 0;
                }
               
$img_num++;
        }
        if(
$a > 0) {
               
$rows_img[] = $img_array;
        }

       
$header = array();

       
$back_url = request_uri();
       
$c_url = count($back_url);
       
$pos = strrpos($back_url, "/");
       
$back_url = substr($back_url, 0, ($pos-$c_url+1));
       
$back_url = preg_replace("/(\?q\=)/", "", $back_url);

       
$output = l('Back to Gallery', $back_url);
       
$output .= theme('table', $header, $rows_img, array('id' => 'imce_gallery_table'));

        return
$output;
}
?>

I then added $userid = arg(1); just under the existing $output = ''; line and replaced the line $path = $folder . '/' . $filename; with $path = 'files' . '/u' . $userid . '/' . $filename;

So basically it looks like this:

<?php
function theme_gallery_items($rows, $folder) {
        global
$base_path;
       
$output = '';
       
$userid = arg(1);

       
$img_num=0;
       
$a = 0;
        foreach(
$rows as $filename) {
#               $path = $folder . '/' . $filename;
               
$path = 'files' . '/u' . $userid . '/' . $filename;
               
$attributes = array("width" => '110', 'border' => '1', 'id' => 'img_'.$img_num, 'name' => 'gallery_images');
               
$img = theme('image', $path, '', '', $attributes, 0);
               
$link_attributes = array('onClick' => 'get_orig("'.$base_path.$path.'", '.$img_num.');return false;');
               
$img_array[$a] = l($img, '', $link_attributes, '', '', '', 1);
               
$a++;
                if(
$a >= 5) {
                       
$rows_img[] = $img_array;
                       
$img_array = array();
                       
$a = 0;
                }
               
$img_num++;
        }
        if(
$a > 0) {
               
$rows_img[] = $img_array;
        }

       
$header = array();

       
$back_url = request_uri();
       
$c_url = count($back_url);
       
$pos = strrpos($back_url, "/");
       
$back_url = substr($back_url, 0, ($pos-$c_url+1));
       
$back_url = preg_replace("/(\?q\=)/", "", $back_url);

       
$output = l('Back to Gallery', $back_url);
       
$output .= theme('table', $header, $rows_img, array('id' => 'imce_gallery_table'));

        return
$output;
}
?>

Now when I go into a user's gallery, the thumbs show up. I'm also able to click on the thumbs and bring up the original image. w00t, she just needs some decent styling now...

The next problem I had was that the Back to Gallery link didn't work at all, it pointed to http://user/9/imce_gallery which ain't right. To tell the truth, I thought about it and figured there was no point in even having this Back to Gallery link anyways, the user should know that he/she can go back using the profile tabs so in the end I just commented out the line:

<?php
$output
= l('Back to Gallery', $back_url);
?>

so

<?php
# $output = l('Back to Gallery', $back_url);
?>

I ran http://www.yourhost.com/update.php to update the modules, and all was well.

Adios!

#5

I resolved the "back" link differently (and it works). I declared

global $base_url;

up top in the function, and then further down, changed the code to read
$back_url = $base_url . preg_replace("/(\?q\=)/", "", $back_url);    // Added '$base_url .' to this to get the right back path.

$output = l('Back to Galleries', $back_url);     // Changed to the plural, as there can be many gallaries.
$output .= theme('table', $header, $rows_img, array('id' => 'imce_gallery_table'));

return $output;

The rest of the code stayed the same, and the back link now works.