Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author David Lingren

    (@dglingren)

    Thanks for your question; the short answer is “yes”.

    You can use a Content Template in the Quick Edit or Bulk Edit areas of the Media/Assistant submenu to assign item-specific values to one or more of your Media Library items. The Title, Caption, Description and ALT Text fields support this feature. More information about Content Templates can be found in the Settings/Media Library Assistant Documentation tab.

    Any of the “Field-level data sources” can be used in your template. For your specific question, you can enter this template in the Caption field:

    template:[+name_only+]

    I am marking this topic resolved, but please update it if you have any problems or further questions about using Content Templates to compose item-specific Quick and Bulk edit values. Thanks for your interest in the plugin.

    Thread Starter robphat

    (@robphat)

    Thanks. I’ll try it!

    David, thanks for your clear description how to do this in another post. This does remove certain elements. For example the filename ‘Maori Club (taiaha) (A$2,800).jpg’ turns a caption ‘Maori-Club-taiaha-A2800’. Can you tell me which characters are being preserved? That way we can change the way we name the source pictures.

    Plugin Author David Lingren

    (@dglingren)

    Thanks for the positive feedback and for your question.

    File naming is handled by WordPress, using its sanitize_file_name function. The first part of the source code for that function includes the characters filtered out:

    /**
     * Sanitizes a filename, replacing whitespace with dashes.
     *
     * Removes special characters that are illegal in filenames on certain
     * operating systems and special characters requiring special escaping
     * to manipulate at the command line. Replaces spaces and consecutive
     * dashes with a single dash. Trims period, dash and underscore from beginning
     * and end of filename.
     *
     * @since 2.1.0
     *
     * @param string $filename The filename to be sanitized
     * @return string The sanitized filename
     */
    function sanitize_file_name( $filename ) {
    	$filename_raw = $filename;
    	$special_chars = array("?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", "~", "!", "{", "}", chr(0));
    	/**
    	 * Filter the list of characters to remove from a filename.
    	 *
    	 * @since 2.8.0
    	 *
    	 * @param array  $special_chars Characters to remove.
    	 * @param string $filename_raw  Filename as it was passed into sanitize_file_name().
    	 */
    	$special_chars = apply_filters( 'sanitize_file_name_chars', $special_chars, $filename_raw );

    The “backtick” character is also removed. There are several filters you can hook to change the sanitizing and naming process.

    I hope that gives you the information you need for your application. Thanks for your interest in the plugin.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Bulk caption edits’ is closed to new replies.