WordPress.org

Ready to get started?Download WordPress

Forums

WP Photo Album Plus
[resolved] Removing .jpg from titles (6 posts)

  1. MarkG76
    Member
    Posted 2 years ago #

    Many thanks to the creators for a great plugin.

    A question on importing photos: The filename is added as the title. Where can I find the function that handles the import so that the ".jpg" part is removed before setting the title of the photo?

    thank you in advance
    Markos

    http://wordpress.org/extend/plugins/wp-photo-album-plus/

  2. Jacob N. Breetvelt
    Member
    Plugin Author

    Posted 2 years ago #

    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);
    }
  3. MarkG76
    Member
    Posted 2 years ago #

    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?

  4. Jacob N. Breetvelt
    Member
    Plugin Author

    Posted 2 years ago #

    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.

  5. MarkG76
    Member
    Posted 2 years ago #

    Many thanks for the response and the code!

  6. aeffemultimedia
    Member
    Posted 2 years ago #

    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);
    ...

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic