Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.
  • When adding an image attachment to a post, the Title field is always filled automatically with the file name.

  • For some images I change this into something more meaningful, for other images I want this field to be empty (in my theme I'm displaying this title field as a caption below each image, but not all images should have this caption).

  • However, if I clear the Title field, it shows again the file name upon save - with the message "Empty Title filled from filename."

  • Any ideas how to change this behaviour, or suggestions for a workaround? I could use the Alt field or Caption field, but I prefer using the Title field - so my client can already fill in the titles by changing the filenames before upload.

share|improve this question

2 Answers 2

up vote 0 down vote accepted

Without a post title, Attachments become significantly harder to use as they no longer have a title that can be clicked on.

If you're processing attachments and generating html manually I recommend using another piece of attachment meta, or just filling in appropriate titles, after all an image is a picture of something, let that something be its name, there's nothing stopping duplicates either.

If you really must remove the title, go to the html tab and manually remove it from the tag. Else put in a placeholder character such as '-'.

Ofnote, attachments are posts too, and that means they have post meta. You could add a checkbox to the edit attachment page, allowing you to toggle on and off wether the attachments title is displayed or not.

share|improve this answer
    
how is not using title attribute generating invalid code? Also your eventual solution is just the same as mine. –  woony Aug 23 '12 at 14:12
    
Can you provide me with a reference to a blank title being a violation of html spec? I don't really think that's true - a title tag is not an alt tag... From the HTML5 spec: "The title attribute can be used for supplemental information." I agree, however, about your comment about not having a title to click on in the UI - I hadn't thought about this, that's a good explanation of why the title field is mandatory. Maybe I'll just use the Alt field instead of the Title field... –  ptriek Aug 23 '12 at 14:45
    
Sorry it is the alt attribute that is mandatory, but that doesn't mean you should be able to have a blank title, as it makes the image/media unselectable in the user interface. –  Tom J Nowell Aug 23 '12 at 15:07
    
@woony Motorolla makes phones, that doesn't stop Nokia and Samsung from trying to outdo them –  Tom J Nowell Aug 23 '12 at 15:08
    
I've updated my answer with edits –  Tom J Nowell Aug 23 '12 at 15:12

Just a suggestion.

use a specific title or charactar for titles you dont want to show. for example. * or # or idontwanttoshowthistitle

Then in your theme, check if title != * or # or idontwanttoshowthistitle to use it as caption.

share|improve this answer
    
thanks, that could be a workaround - but i prefer a 'cleaner' solution, since it's for a client... –  ptriek Aug 23 '12 at 14:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.