Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter kevin360

    (@kevin360)

    Thank you Ollie for taking the time to send that to me. I’ll try working with that to see if I can get it to do what I’m wanting to do.

    Thread Starter kevin360

    (@kevin360)

    I’m not sure I agree that telling people how to do something is suggesting that they do, do that thing.

    But, you bring up a good point, yes it is hacking at the core WP files. So is there a way to do this without hacking at the core files?

    Thread Starter kevin360

    (@kevin360)

    Actually just figured it out! Decided to output the entire attachment array to see what’s in there and the title isn’t even in there. Found that I need to use $post->post_title to get it. So if anyone else wants to do this, in wp-admin/includes/ajax-actions.php change this line:

    $title = ''; // We no longer insert title tags into <img> tags, as they are redundant.*/

    to this:

    $title = isset( $post->post_title ) ? $post->post_title : '';

    Then you also need to edit media.php in wp-admin/includes/ Go to function get_image_send_to_editor and change this line:

    $html = get_image_tag($id, $alt, '', $align, $size);

    to this

    $html = get_image_tag($id, $alt, $title, $align, $size);

    Now you will have the Title from the media manager field inserted into the title field of the image.

    If you also want the Title from the media manager field inserted into the Advanced Link Settings -> Title field, then you’ll need to change this line in the function also:

    $html = '<a href="' . esc_attr($url) . "\"$rel>$html</a>";

    to this:

    $html = '<a href="' . esc_attr($url) . "\" title=\"$title\" $rel>$html </a>";

    As an end user it’s not really clear why the Title from the media manager isn’t automatically inserted as the title into the post. I’m sure there is a reason it’s not done, it just isn’t apparent to me. When I fill in the Title field and insert an image and then I click on the Edit Image modal and the Title field is blank, it’s confusing why that would be.

    Thread Starter kevin360

    (@kevin360)

    That’s what I’ve done in the past and why I edited the previous version of WP to automatically insert the title. Instead of always having to re-edit the image I just inserted to add the title, I edited the code so it was always inserted for me. At least it was working in the previous version of WP. I can force it to be set to the “Alt Test” field, just not the Title field which is what’s odd about it.

Viewing 4 replies - 1 through 4 (of 4 total)