I am using a form field to let a user edit a post and upload a profile image.
Once they upload the profile image a URL is passed to a hidden custom text field called 'logo_header'. I read this URL in the PHP template and use it to display the image as follows.
<?php $logo = get_post_meta($post->ID, 'logo_header', true); ?>
<div class="profileLogo"><img src="<?php echo $logo; ?>" /></div>
My Problem is when a user decides to update their photo (basically change the photo) the new URL is just added to the end of the current one, I guess this creates an array. so it would be like
http://example.com/myprofile.jpg, http://example.com/myprofile2.jpg
Obviously the image src cannot use an array, it needs 1 URL.
I use gravity forms upload file button to edit the post and upload the image. There is no option to delete the current image that already exists (Thats another problem :( ) so the user is only given an upload button.
My question is
How can I always choose the last URL added to the 'logo_header' field?