Support » Themes and Templates » wp_get_attachment_image – How to include alt and title fields?

  • Resolved bmlcreative



    I’m creating a gallery using the latest aino galleria plugin and have got everything working as I need it to, but when the images are pulled in from WordPress post pages, they are not bringing in the ‘alt’ and ‘title’ attributes that I have added. Instead, they are just using the filename of the image.

    I’ve read that this is an issue with WP and there was a suggestion on WordPress Trac but didn’t seem to work and haven’t been able to find a fix that works with 3.0.

    Here’s what I have inside my loop:

    <div id="portfolioitemcontainer">
    <div class="post" id="post-<?php the_ID(); ?>">
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div id="galleria">
           <?php $attachments = get_children( array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' => 'image') );
    	foreach ( $attachments as $attachment_id => $attachment ) {
    	echo wp_get_attachment_image($attachment_id, $size='full', $icon = false);
    	} ?>
    	<?php endwhile; ?>
    	<?php else : ?>
    	<h2>Not Found</h2>
    	<?php endif; ?>

    Any suggestions greatly welcomed…

Viewing 1 replies (of 1 total)
  • Ah – hang on a minute – it’s all working – seems there was a conflict with the data_config: function(img) within galleria that was stripping any tags. removing that has resolved the issue!

Viewing 1 replies (of 1 total)
  • The topic ‘wp_get_attachment_image – How to include alt and title fields?’ is closed to new replies.