• Resolved noelgreen

    (@noelgreen)


    I have the following code to grab the thumbnail images from the posts.

    <?php
    $attachments = get_children("post_parent={$post->ID}&post_type=attachment&post_mime_type=image&numberposts=1");
    foreach ( $attachments as $att_id => $attachment) {
    echo wp_get_attachment_image($att_id, 'thumbnail');
    }
    ?>

    That works great. But I need to remove / not display / hide the “Title” of the image. So that when someone does a mouse over on the image it won’t display the “title” as a pop-up.

    Any ideas?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter noelgreen

    (@noelgreen)

    Figured it out.
    Based on this post I changed my code to this.

    <?php
    $featured_image = array();
    $args = array(
    	'post_type' => 'attachment',
    	'numberposts' => 1,
    	'post_status' => null,
    	'orderby' => ID,
    	'post_parent' => $post->ID
    	);
    $attachments = get_posts($args);
    if ($attachments) {
    	foreach ($attachments as $attachment) {
    		$featured_image = wp_get_attachment_image_src($attachment->ID, $size='thumbnail', $icon = false);
    	}
    }
    echo '<img src="' . $featured_image[0] . '" alt=""/>';
    ?>

    Also, in 2.9.2 you can open up media.php and comment out line 565.

    //'title' => trim(strip_tags( $attachment->post_title ))
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Remove Img Title’ is closed to new replies.