Get Post meta showing a blank image

Hi,

I am using the following to code for two custom fields. When an image is inserted, there is no box underneath. If a video is inserted, a blank image/block shows up beneath it. There should be nothing. Im only inserting one or the other. I am pretty sure I am missing the echo part for the image if it is true, but I have tried several things with no luck. Any help is appreciated. I have included a screen shot as well…

<?php  if((get_post_meta($post->ID, "video", true))) { ?>
				<?php echo get_post_meta($post->ID, "video", true); ?>
				<?php } ?>	
			
				
				<?php  if((get_post_meta($post->ID, "image", true))) { ?>
			<?php
				$images = array(
				'example.jpg',
				'example.jpg',
				'example.jpg',
				'example.jpg',
				);
				$image  = $images[array_rand($images)];
				$output = "<img src=\\"http://examplesite.com/images/random/" . $image . "\\" />";
				echo $output;
			?>
			<?php } ?>	

If both are showing up, then clearly the culprit is

if((get_post_meta($post->ID, “image”, true)))

returning true when it shouldn’t.

If both are supposed to be true, but you just don’t want the image portion to run if a video is present, then you would change

if((get_post_meta($post->ID, “image”, true)))

to

else if((get_post_meta($post->ID, “image”, true)))

Thank you. I figured the image is the problem, but I am not sure how to get it to display true only if it is true. If its not, it does nothing. The video is working properly.

I’m a little confused so bare with me here, from what i can gather you have two custom fields in which only one can be displayed at a time?

If that’s right then a question i have for you would be what would you like to happen if both fields have a value in it?

I ask because the logic wonshikee used is doing exactly what you need it to do so why not just set a variable to say if “video” is present and “image” is present ignore “image”.

After rereading it, I have determined that you are correct and that I am an idiot. :eek:… With that out the way, I am getting a unexpected T_ELSE when I change the “if”
to “else if”

changed it up from the above recommendations, but still getting the blank image below the vid.

<?php  if((get_post_meta($post->ID, "video", true))) { ?>
				<?php echo get_post_meta($post->ID, "video", true); ?>
				
				<?php } else if((get_post_meta($post->ID, "image", true))) { ?>
			<?php
				$images = array(
				'example.jpg',
				'example.jpg',
				'example.jpg',
				'example.jpg',
				);
				$image  = $images[array_rand($images)];
				$output = "<img src=\\"http://examplesite.com/images/random/" . $image . "\\" />";
				echo $output;
			?>
			<?php } ?>

The box was a style sheet issue. I guess it was just one of those days. Thanks to the both of you for the help!