WordPress.org

Support

Support » Plugins and Hacks » [Resolved] [Plugin: WP Photo Album Plus] Removing .jpg from titles

[Resolved] [Plugin: WP Photo Album Plus] Removing .jpg from titles

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Jacob N. Breetvelt
    Participant

    @opajaap

    You can remove the .jpg in the Photo Albums admin page, click the green Edit of the album involved, scroll down to edit the photo names.

    It is NOT a good idea to change the names. If you want to update your photos later (e.g. to resize them to a different fullsize as before) the names should be the same as the filenames.

    If you really want to remove the .jpg on all subsequent upload/imports change the following: wppa-upload.php line 706:

    // Add photo to db
    $query = $wpdb->prepare('INSERT INTO <code>' . WPPA_PHOTOS . '</code> (<code>id</code>, <code>album</code>, <code>ext</code>, <code>name</code>, <code>p_order</code>, <code>description</code>, <code>mean_rating</code>, <code>linkurl</code>, <code>linktitle</code>, <code>timestamp</code>, <code>owner</code>) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)', $id, $album, $ext, $name, $porder, $desc, $mrat, $linkurl, $linktitle, time(), $owner);
    if ($wpdb->query($query) === false) {
    	wppa_error_message(__('Could not insert photo. query=', 'wppa').$query);
    }

    change to:

    // Add photo to db
    if (strlen($name) > 4) $name = substr($name, 0, -4);
    $query = $wpdb->prepare('INSERT INTO <code>' . WPPA_PHOTOS . '</code> (<code>id</code>, <code>album</code>, <code>ext</code>, <code>name</code>, <code>p_order</code>, <code>description</code>, <code>mean_rating</code>, <code>linkurl</code>, <code>linktitle</code>, <code>timestamp</code>, <code>owner</code>) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)', $id, $album, $ext, $name, $porder, $desc, $mrat, $linkurl, $linktitle, time(), $owner);
    if ($wpdb->query($query) === false) {
    	wppa_error_message(__('Could not insert photo. query=', 'wppa').$query);
    }

    Many thanks for the quick response! I didnt know the issue about the title of the photo being the same with the filename for updates.

    How about not changing the database but just doing an str_replace(‘.jpg’,”) on the name of the photo when displaying it? Would that create any issues?

    Plugin Author Jacob N. Breetvelt
    Participant

    @opajaap

    Thats ok, but we (you) have to find probably several places in the code to do that, or put it in the qTanslate filter in wppa-common-functions.php around line 578:

    // qtrans hook for multi language support of content
    function wppa_qtrans($output, $lang = '') {
    	if ($lang == '') {
    		if (function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')) {
    			$output = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($output);
    		}
    	} else {
    		if (function_exists('qtrans_use')) {
    			$output = qtrans_use($lang, $output, false);
    		}
    	}
    	return $output;
    }

    Change return $output; into return str_replace('.jpg','',$output);
    this will remove all .jpg ‘s in any name and/or description output.

    BTW I will NOT put this into standard code.

    Many thanks for the response and the code!

    noname
    Member

    @aeffemultimedia

    If you want to update ONLY photos of which you removed extension from name, you can temporarily add the same line in file wppa-upload.php, function wppa_update_photo at line 841:

    ...
    if ($xname == '') $name = basename($file);
    else $name = wppa_qtrans($xname);
    
    // ADD THE FOLLOWING LINE
    if (strlen($name) > 4) $name = substr($name, 0, -4);
    ...

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] [Plugin: WP Photo Album Plus] Removing .jpg from titles’ is closed to new replies.