• Resolved bluecedardesign

    (@bluecedardesign)


    Obviously I’m doing something wrong here, but can’t figure out the solution. I’m attempting to use CFT in a CMS for a portfolio site, calling thumbnail images that link to the full portfolio image in lightbox. Here’s the code I have:

    <?php if(get_post_meta($post->ID, "portfolio_image", true)) { ?>
    
    <a href="<?php echo get_post_meta($post->ID, "portfolio_image", true); ?>" rel="lightbox[<?php the_ID(); ?>]">
    <img src="<?php if(get_post_meta($post->ID, "portfolio_thumbnail", true)) { ?><?php echo get_post_meta($post->ID, "portfolio_thumbnail", true); ?><?php } ?>" title="<?php the_title(); ?>" alt="<?php the_title(); ?>">
    </a>
    
    <?php } ?>

    Instead of getting an image, I’m only getting the alt for the link and the lightbox just spins. I know that the images have been uploaded through CFT, so they’re definitely there, but I also realize I’m not calling them up correctly.

    Would appreciate any help I could get.

    https://www.ads-software.com/extend/plugins/custom-field-template/

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

    (@bluecedardesign)

    Also, this is what I have for my template options:

    [portfolio_image]
    type = file
    relation = true

    [portfolio_thumbnail]
    type = file
    relation = true

    Thread Starter bluecedardesign

    (@bluecedardesign)

    So after further research, I found out that for some reason CFT is assigning a number value to the images I’m uploading, rather than using the URL as a value.

    How do I make sure that the value assigned to each image is the URL rather than a number?

    Thread Starter bluecedardesign

    (@bluecedardesign)

    Figured out my own problem. Had to use wp_get_attachment_url:

    <?php if(get_post_meta($post->ID, "portfolio_image", true)) { ?>
    
                                    <a href="<?php $portfolio_image = get_post_meta($post->ID, 'portfolio_image', true);
    echo wp_get_attachment_url($portfolio_image); ?>" rel="lightbox[<?php the_ID(); ?>]"><img src="<?php $portfolio_thumbnail = get_post_meta($post->ID, 'portfolio_thumbnail', true);
    echo wp_get_attachment_url($portfolio_thumbnail); ?>" title="<?php the_title(); ?>" alt="<?php the_title(); ?>"></a>
    
                                    <?php } ?>

    Took all day, but I hope this may help someone else!

    Such a good habit to post solutions we find alone. Thanks for sharing. ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom Field Template not calling images in PHP’ is closed to new replies.