WordPress.org

Ready to get started?Download WordPress

Forums

Simple Fields
[resolved] Images hide of none selected (2 posts)

  1. 50slespaul
    Member
    Posted 2 years ago #

    Wondering if there is a way to hide the field if an image isn't selected in the admin?

    calling an image like so:

    <?php $imgsrc = wp_get_attachment_image_src($getfields["Image"][$count], 'Image'); ?>

    <img src="/wp/wp-content/themes/mytheme/phpThumb.php?src=<?=$imgsrc[0]?>&w=100&h=100&zc=1" alt="<?php echo($getfields["Name"][$count])?>" title="<?php echo($getfields["Name"][$count])?>

    but if a user does not select an image in the admin, I want to have the whole <img> tag gone so there is nothing there... I am gettimg an empty img tag now... anyone?

    http://wordpress.org/extend/plugins/simple-fields/

  2. Pär Thernström
    Member
    Plugin Author

    Posted 2 years ago #

    Can'y you just check if $imgsrc contains anything?

    Like
    if ($imgsrc) {
    // output image...

    or perhaps

    if (isset($imgsrc)) {
    // output image...

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.