Thread Starter
syni
(@syni)
Well, reading the Codex article about Custom Fields, I don’t think you can specify images as meta data… so is there any possible way to do this?
“I don’t think you can specify images as meta data.”
Why so quick to decide that?
There a number of ways you can go about this. My suggestion is this bit of code:
<?php if(get_post_custom_values('img')) :
foreach(get_post_custom_values('img') as $value) {
echo '<img src="' . $value . '" />';
}
else :
echo '<img src="no-image.gif" />';
endif; ?>
Note this assumes use of ‘img’ for the custom field key. You may want to spiff up the img tags with height, width and title attributes. I also assume you’re providing the full filename (and possibly path to image) as the field value, when you can use the script to take care of much of that. For example, if images reside in /images/, and all images will be GIFs, you could just use the name of the file without extension, and change the code to:
echo '<img src="/images/' . $value . '.gif" />';
Thread Starter
syni
(@syni)
Haha, well, I guess I have a hard time thinking outside the box when it comes to PHP and stuff like that. Thanks Kafkaesqui, I was hoping that you’d come up with something. 🙂 I’ll try this out.
I’m very interested in this too..
are there any plugins in existance that allow file upload and insertion of the image url into the value field of a custom field? (or something similar for conveniently adding images to custom fields).
cbit, did you find anything to insert an image automatically into a custom field? i imagine you could do this by hacking an image plugin, but i’m not enough of a programmer to do this 😛
I’m still really interested in this. I don’t have time to make my own thumnails for all posts (especially with other folk adding posts themselves as well)… it needs to be automated….
am using the whole Post Instad ….. thanx for that tip