Support » Fixing WordPress » Image titles have dashes upon upload

  • I’ve noticed a weird issue that came up randomly on my site. I’ve noticed in the last couple days that when I upload images they no longer get a proper title. For example, I will upload an image called Funny Dog.jpg the title WordPress would usually give it is Funny Dog. However when I upload it now it generates the title as funny-dog. I’ve deactivated all my plugins, but this hasn’t made a difference. Has anyone else experienced this issue?

Viewing 15 replies - 1 through 15 (of 16 total)
  • Aye, what happened with that ๐Ÿ™
    Would be nice to get it back as it was.

    Having the same thing happen and nice to see it’s not isolated.

    This appears to be a “feature” of WordPress 4.6.

    I just upgraded and have the same problem. A real pain in the neck, as I’ll have to retype all my image titles every time I load a new image, and I load hundreds.

    I have no idea why they would have changed it. Any insights from the designers would be helpful. Is it for SEO purposes???????

    Argh!!

    Feature? This only happened after upgrade to 4.6.1.

    Any idea to roll back?

    The other problem if the file name is with uppuercase is imported in lowcase. Ex. DSC_0303.jpg = dsc_0303.
    Solutions?

    WP did this back in 2013 and it was short lived thankfully.

    Yes there’s a solution on how get the previous version, Add define( 'WP_AUTO_UPDATE_CORE', false ); in wp-config.php file to prevent future auto update of WordPress.

    Now backup your site phpmyadmin database. Now go to your cpanel and find your WordPress files. [Do not delete] these files and folders wp-config.php, wp-content, .htaccess. Now select and backup the rest of the folders and files into a zip file in your cpanel root directory.

    Now go and download wordpress previous version 4.6. Extract wordpress zip file on your local PC and delete wp-config.php, wp-content folder.

    Select all the rest of the files and put it into a zip file then upload into your cpanel finally extract the wordpress .zip file into your wordpress site directory. Now load your site admin dashboard and you will see that you are using the previous version of WP.

    Delete wordpress .zip file after you have done everything.

    @gooma2 Do you know how to fix it?

    I’m going to check with our developer (on vacation of course) to see what tweak to make as it’s very annoying for those of us that have news sites with a lot of images posted daily.

    Automatically add Alt Tag to WordPress Image Uploads https://wordpress.org/support/topic/automatically-add-alt-tag-to-wordpress-image-uploads/

    Here is a solution to fix the problem by automate add alt when upload images, that means you won’t need to modify the title already add dashes, just make the right alt text.

    Thanks for sharing the link and the code. I have modified the code to myself and the problem seems to be resolved with the below code:

    add_action( 'add_attachment', 'ced_add_image_meta_data' );
    function ced_add_image_meta_data( $attachment_ID ) {
    
     $filename   =   $_REQUEST['name']; // or get_post by ID
     $withoutExt =   preg_replace('/\\.[^.\\s]{3,4}$/', '', $filename);
     $withoutExt =   str_replace(array('-','_'), ' ', $withoutExt);
    
     $my_post = array(
       'post_title' => $withoutExt,  // title
       'ID'           => $attachment_ID,
       'post_excerpt' => $withoutExt,  // caption
       'post_content' => $withoutExt,  // description
     );
     wp_update_post( $my_post );
     // update alt text for post
     update_post_meta($attachment_ID, '_wp_attachment_image_alt', $withoutExt );
    }

    post_title is the Image title name which replaces the dashes and small alphabets to the original file name.

    If you don’t need to auto add image file name in Alt and Description field remove the caption and description line from the above code. ๐Ÿ™‚

    @onsecrethunt Nice! Yes, I think the code is easy to modify to meet your need.

    Thanks so much for the code @onsecrethunt it works great!

    Hopefully WordPress will change the titles back in a future version.

    Apparently it’s a bug introduced in 4.6.1 by changes to the image file naming part of the code.

    According to the release notes for 4.6.1 (https://wordpress.org/news/2016/09/wordpress-4-6-1-security-and-maintenance-release/):

    “WordPress versions 4.6 and earlier are affected by two security issues: a cross-site scripting vulnerability via image filename, reported by SumOfPwn researcher Cengiz Han Sahin and a path traversal vulnerability in the upgrade package uploader, reported by Dominik Schilling from the WordPress security team.”

    So, I guess in their effort to fix the “cross-site scripting vulnerability via image filenames,” they also changed the image titles to include the hyphens that are part of those filenames…

    Anyone know how to report a bug to the WordPress team??

    This link might help to create a ticket and report the issue to WordPress team.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Image titles have dashes upon upload’ is closed to new replies.