• Resolved Okoth1

    (@okoth1)


    I’m trying to use the alt as a title, but I’m stuck.

    I’ve set titleFromAlt in fancybox/jquery.fancybox-1.3.4.js and fancybox/jquery.fancybox-1.3.4.pack.js to true, but no results.
    If I’m right, there are no titleFromAlt settings in easy-fancybox.php anymore.

    Could someone help me on my way?

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • Easy FancyBox still has the option “Allow title from thumbnail alt tag” which corresponds with the “titleFromAlt” switch in FancyBox.

    There is no need to edit any plugin or script files to achieve it. You just have to make sure the thumbnail (not the link) has an alt attribute and the link does NOT have a title attribute. If the link itself has a title attribute, it will prevail over any alt attribute on the thumbnail image…

    Thread Starter Okoth1

    (@okoth1)

    Sounds good. I’m going to look at it. Thanks for the quick reply.

    Thread Starter Okoth1

    (@okoth1)

    Still struggling to call the alt tag used in Media.

    I’m trying to use this, but it doesn’t include the alt.

    <div class="kader">
    <?php
    $debut = 0; //The first article to be displayed
    ?>
    <?php while(have_posts()) : the_post(); ?>
    <?php
    $myposts = get_posts('category_name="foto"&posts_per_page=-1');
    foreach($myposts as $post) :
    setup_postdata($post);
    ?>
    <article <?php post_class() ?> id="post-<?php the_ID(); ?>">
    <div class="entry"><div class="postmain">
    <?php $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), '', false, '' ); $thumbnailSrc = $src[0]; ?>
    <?php $alt = get_post_meta($attachment->$post->ID, '_wp_attachment_image_alt', true); ?>
    <a href="<?php echo $thumbnailSrc;?>"><img class="ethumb" src="<?php bloginfo('template_directory'); ?>/timthumb.php?src=<?php echo $thumbnailSrc;?>&h=149&w=149&zc=1" alt="<?php echo $alt; ?>"/></a>
    </div></div>
    </article>
    <?php endforeach; ?>
    <?php endwhile; ?>
    </div>

    Any ideas. The page is a page with posts.

    Im not sure if $attachment->$post->ID actually refers to the posts attachment.. What happens when you try something like:

    <?php $alt = get_post_meta( get_post_thumbnail_id($post->ID), '_wp_attachment_image_alt', true ); ?>

    Either method might actually populate $alt with an array. To debug, use <?php print_r($alt); ?>

    Thread Starter Okoth1

    (@okoth1)

    Excellent! Works well for the title tag too. I use it now like this:

    <article <?php post_class() ?> id="post-<?php the_ID(); ?>">
    <div class="entry"><div class="postmain">
    <?php
    $alt = get_post_meta( get_post_thumbnail_id($post->ID), '_wp_attachment_image_alt', true );
    $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), '', false, '' ); $thumbnailSrc = $src[0]; ?>
    <a href="<?php echo $thumbnailSrc;?>" title="<?php echo $alt; ?>"><img class="ethumb"  src="<?php bloginfo('template_directory'); ?>/timthumb.php?src=<?php echo $thumbnailSrc;?>&h=149&w=149&zc=1" alt="<?php echo $alt; ?>"/></a>
    </div></div>
    </article>

    Thanks for thinking with me!

    Btw, for other people, this code combines Featured Image with timthumb.php. Featured Images will be automatically scaled to fit.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘titleFromAlt’ is closed to new replies.