Support

Account

Home Forums General Issues Display image on condition of selection Reply To: Display image on condition of selection

  • Hi,

    If you have a select field without multiple select it should just return a value not an array..

    This code might get you in the right direction:

    
    <?php 
    $activity_rating = get_field('activity_rating');
    
    switch($activity_rating){
    	
    	case '1':
    		$img = 'urltoimage';
    		break;
    	case '2':
    		$img = 'urltoimage2';
    		break;
    	case '3':
    		$img = 'urltoimage3';
    		break;
    	case '4':
    		$img = 'urltoimage4';
    		break;
    	case '5':
    		$img = 'urltoimage5';
    		break;
    	case default:
    		$img = 'fallbackimage';
    		break;
    		
    	echo '<img src="' . $img . '" alt="" />';
    	
    }
    ?>