WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using nextgen gallery plugin with this code:

$galleries = $wpdb->get_results(
"SELECT t.*, tt.* 
FROM $wpdb->nggallery AS t 
INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid 
WHERE tt.exclude != 1 
GROUP BY tt.galleryid ORDER by tt.galleryid");

echo do_shortcode('[nggallery id='.$galleries[0]->gid.' template=galleryview images=0]'); 

echo '<ul>';
foreach ( $galleries as $gallery ) {
    $img_date = explode("-", $gallery->imagedate);
    $ano = $img_date[0];
    $mes = $img_date[1];
    $img_gallery_url = get_bloginfo('url').'/wp-content/uploads/'.$ano.'/'.$mes.'/'.$gallery->filename;
    // $gallery->filename trazendo lowercase
            <img width="139px" height="83px" src="'.$img_gallery_url.'" alt="'.$gallery->alttext.'"/>
            <a href="#">'.$gallery->name.'</a>
echo '</ul>';

But the $gallery->filename is coming lowercase. My images are being saved without being mandatory to be lowercase.

  • How could I fix this ?
  • Is there a way to make mandatory lowercase in wordpress image upload (nextgen gallery)?
  • Is there a way to make $gallery->filename bring the right filename, without making it lowercase ?
share|improve this question

closed as off-topic by Pieter Goosen, cybmeta, kaiser Nov 22 '14 at 8:49

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

DataBase handling

ALWAYS do a proper prepare() when receiving data from the DB.

I can't say it often enough…

$galleries = $wpdb->get_results( 
    $wpdb->prepare( "
        SELECT t.*, tt.* 
        FROM %s AS t 
        INNER JOIN $wpdb->nggpictures AS tt ON t.gid = tt.galleryid 
        WHERE tt.exclude != 1 
        GROUP BY tt.galleryid ORDER by tt.galleryid
    " ), 


…simply isn't involved. You're doing a normal request via the WP DB class object. So the problem is completely elsewhere. I'd suggest to turn off all plugins aside from NextGen, activate the default TwentyTen/Eleven Theme, drop your code in there and then see if it happens again.

Update: If the plugin is lowercasing the files…

In this case, the nextgen plugin is (90% chance that it's that way) lowercaseing the files on upload. Not much what you can do against it without killing the plugin itself (updates, core changes, etc.).

My suggestion:

  1. Fix it when calling the files if you want a prettier output. ucwords, mb_strtoupper(), etc.
  2. Don't fix it if it's only about the filename.
share|improve this answer
in wp_ngg_pictures (database table) the filename is all saved as lowercase, and the images in my folder are with normal text (uppercase, first uppercase the others lowercase ...). The idea for the theme and plugin didn't work. Any other ideas ? – Michel Ayres Apr 3 '12 at 18:38
see update .... – kaiser Apr 3 '12 at 18:46
my problem is not the filename prettier. for example. my file (in the folder) is named "WinteR.jpg", I want to use this filename as a src from img exhibition. But the filename is always lowercase. So I want get the file name as it is in the folder OR save in the database the filename as it is in the folder. not lowering. – Michel Ayres Apr 3 '12 at 19:01
up vote 0 down vote accepted

After some pain, I found this at the plugin documentation

For a single picture : [singlepic id=x w=width h=height mode=web20|watermark float=left|right]

So my echo became this:

    '.do_shortcode('[singlepic id='.$gallery->previewpic.' w=139 h=83 float=left]').'
    <a href="#">'.$gallery->title.'</a>
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.