Support » Fixing WordPress » Conditional Thumbnail Display? Check for thumbnail, if not, display code

  • Ian

    (@ianaleksander)


    So I’ve got a weird idea.

    I want wordpress to check to see if a post has a thumbnail / featured image. If it does, I want it to display the image, either in thumb size or one of the other featured image sizes depending on how I call it.

    but if there isn’t one, I want wordpress to excecute different code. In this case I want it to use an isbn number gotten from a custom field to grab an image from amazon.

    That code I’ve got:

    <?php echo c2c_get_custom('isbn-10', '<img src="http://images.amazon.com/images/P/','.01.LZZZZZZZ.jpg" alt="Book Cover" /></a>'); ?>

    Though I’d like to replace “Book Cover” with the title, but wasn’t sure if I could put php inside that other php. I’m still not clear on the formatting.

    Anyone know how I might do this?

Viewing 4 replies - 16 through 19 (of 19 total)
  • I do understand where you’re coming from 😉

    Moderator keesiemeijer

    (@keesiemeijer)

    If your code works as you want to, don’t change it. the code in the link flick gave you is for theme developers who want to have on the fly image sizes that you didn’t specify in the WordPress admin Media panel under Settings > Media or with add_image_size() so their theme works as they want to. If your code works don’t change it, it is not much load on the server

    Ian

    (@ianaleksander)

    It works! But it also worked with a lack of tags, haha. It sometimes seems like things are working perfectly fine, but the code technically has errors in it. i worry they will be problems down the line

    But I’m pretty happy with this right now. I think the nested else statements might be cumbersome, but they’re not technically incorrect.

    Thanks again for your help.

    Thanks for the clarification, keesiemeijer!

Viewing 4 replies - 16 through 19 (of 19 total)
  • The topic ‘Conditional Thumbnail Display? Check for thumbnail, if not, display code’ is closed to new replies.