Support

Account

Home Forums General Issues Replace radio returned value by image

Solved

Replace radio returned value by image

    • Manuc

    • July 17, 2013 at 7:55 pm

    Hello,

    is it possible to replace the returned value of a radio button by an image please ?

    Exemple for difficulty level.

    In admin / radio field creation :
    Very simple : very simple
    Simple : simple
    Normal : Normal

    And the returned result in front for :
    “Very simple” is : one star (a picture of one star)
    “Simple” is : two star (picture of two stars)
    “Normal” is : three star (picture of three stars)

    • Elliot

    • July 18, 2013 at 2:39 pm

    Hi @manuc

    Yes, this is an easy task that you can accomplish with the following code:

    
    <?php 
    
    $map = array(
    	'Very simple' => 'url/to/image.jpg',
    	'Simple' => 'url/to/image.jpg',
    	'Normal' => 'url/to/image.jpg',
    );
    
    $value = get_field('field_name');
    
    $image = $map[ $value ];
    
    ?>
    <img src="<?php echo $image; ?>" />
    
    • Manuc

    • July 18, 2013 at 10:16 pm

    Many thanks to you Elliot !!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.