Support » Plugin: WordPress Gallery Plugin - NextGEN Gallery » [Plugin: NextGEN Gallery] Renaming a photo in ngg.uploadImage causes numerous issues

  • Hi Alex,

    I noticed a rather nasty bug in ngg.uploadImage.
    If you specify overwrite=true and provide a new file name for an existing image, the plug-in replaces the original photo, however the thumbnail keeps the old name. Also, the database information for that image remains unchanged. So if you attempt to rename the photo one more time the call would fail with with a “Failed to delete image” error (because the name in the database no longer matches the filename.

    I am suggesting the following changes:

    1. delete the thumbnail after deleting the original image:

    if ( !@unlink( $image->thumbPath ) ) {
    				$errorString = sprintf(__('Failed to delete thumbnail %1$s ','nggallery'), $image->thumbPath);
    				logIO('O', '(NGG) ' . $errorString);
    				return new IXR_Error(500, $errorString);
    			}

    2. update the filename and reset the image after placing the uploaded photo in the destination folder:

    if(!empty($data["overwrite"]) && ($data["overwrite"] == true)) {
    			if ($filename != $image->filename) {
    				$result = nggdb::update_image($pid, false, $filename);
    				$image = null;
    			}
    		}

    http://wordpress.org/extend/plugins/nextgen-gallery/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: NextGEN Gallery] Renaming a photo in ngg.uploadImage causes numerous issues’ is closed to new replies.