WordPress.org

Ready to get started?Download WordPress

Forums

How to get the "alt" and "title" information for an image? (6 posts)

  1. Pierreb
    Member
    Posted 4 years ago #

    I'm trying to find out how to get the specific information entered for each image.

    Scenario goes like this...
    1. User uploads an image as usual and enter the Alternative text and Title for the image.
    2. The image is later shown using custom fields in the template.

    The code below will get the page/post title for both "alt" and "title", but that's not what I want.
    ...
    '" alt="' . get_the_title() . '" title="' . get_the_title() . '"
    ...

    I'm looking for a tag to replace get_the_title() for both "alt" and "title". get_the_image_title and get_the_image_alt_title would be two good ones for my purpose :-)

    Been looking allover in the codex without success. Anyone have a clue on this one?

    There must be a function for this, right? Or do I really have to make custom fields for "alt" and "title" as well?

  2. Pierreb
    Member
    Posted 4 years ago #

    *bump*

  3. doc4
    Member
    Posted 4 years ago #

    Pierreb,

    If not using custom fields, where would the alt and title come from? Has this information already been supplied by the uploader?

    From what I understand the post title is not necessarily the title of the image, but the uploader has a custom field to enter the image title, correct. What are you expecting to see as the alt title?

  4. Pierreb
    Member
    Posted 4 years ago #

    doc4,

    I know I can solve it using an extra custom field for the description/alt text. And so have I done now, but the user in this case is not a friend of computers. So when I said that they have to enter the information twice, on upload and then in the custom field(s), I saw their face changed a bit :-)

    Perhaps the new thumbnail feature in WP will solve this in the future?

    Thanks.

  5. doc4
    Member
    Posted 4 years ago #

    Pierreb,

    This makes sense now and I'm wondering why the 'alt' isn't working.

    Just to clear this up for anyone else. The image 'alt' description is an option within WordPress and appears when uploading or editing an image.

  6. doc4
    Member
    Posted 4 years ago #

    Pierreb,

    Take a look at this post on this same topic. http://wordpress.org/extend/ideas/topic/require-alt-text-during-uploading-images

Topic Closed

This topic has been closed to new replies.

About this Topic