Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
    echo 
        '<li>
            <img width="139px" height="83px" src="'.$img_gallery_url.'" alt="'.$gallery->alttext.'"/>
            <a href="#">'.$gallery->name.'</a>
        </li>';
}
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
add comment

2 Answers

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
    " ), 
    $wpdb->nggallery 
);

NextGen…

…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
add comment
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:

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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