• I have plenty of images with long descriptive file names. I would like to upload them to WP, to a gallery, where I need to show their descriptions. I have thought, that it is a basic function, but after 15 hours of searching and attempting I can’t believe that it isn’t there (or I do something wrong).

    I tried https://www.ads-software.com/support/topic/display-title-as-caption-in-wp-gallery, there isn’t mentioned which functions.php to modify:
    in themes this do nothing
    in wp-include WP notifies: undefined function add_action() (next 2 hours searching how to solve it – if I understood this is not proper one)

    I tried to modify media-template.php: https://unsalkorkmaz.com/wp3-5-media-gallery-edit-modal-change-captions-to-title/ – this simple substitution in the begin of this article, but it didn’t help (it is difficult to me to understand whole program).

    I tried or explored a few plugins (Media Library Assistant, File Gallery, Format Media Titles, Image Formatr, Image Metadata Cruncher).

    Then I tried to show file names (or titles) instead of caption under images using short codes or NextGEN Gallery (which doesn’t support accent file names and in the end doesn’t work at all).

    The only solution I have found is to modify database directly:
    UPDATEwp_postsSETpost_excerpt=post_title WHEREpost_type= "attachment" ANDpost_excerpt= ""
    ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter bobo8

    (@bobo8)

    Nobody?

    Then I have written a scipt for it and included it in a plugin:

    <?php
    // Copy Title to Caption in attachments
    mysql_select_db(DB_NAME)
    or die("Unable to select database: " . mysql_error());
    $query = "SELECT * FROM wp_posts WHERE post_type= 'attachment' AND post_excerpt= ''";
    $result = mysql_query($query);
    if (!$result) die ("Database access failed: " . mysql_error());
    $rows = mysql_num_rows($result);
    $query = "UPDATE wp_posts SET post_excerpt=post_title WHERE post_type='attachment' AND post_excerpt=''";
    $result = mysql_query($query);
    if (!$result) die ("Database access failed: " . mysql_error());
    echo 'Captions changed: ' . $rows;
    echo "\n"; ?>

    how I use this to get filenames as caption in built in gallery and on lightbox?

    @lemuelmas: If you require assistance then, as per the Forum Welcome, please post your own topic.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘automatic inserting media file names into caption on uploading’ is closed to new replies.