Version 2.0 adds a feature that should have been there from the beginning: instead of storing the image URL, it stores the image ID (for images uploaded to the site), along with the desired size.
You’ll notice the change when you use the Insert CFI button to add an image. Otherwise, you can still add the URL by hand.
A Default URL option was also added in this version, so that all posts can have an image, making your site more uniform.
The template tags have also changed, for the better, I hope.
These are the declaration for the template tags now:
custom_field_image($post_id = '', $defaults = ''); get_custom_field_image($post_id = '', $defaults = '', $format = 'html');
Say you want to override the default alignment. You can do that by adding this code:
If you also wanted to override the alt text, you would do this:
And so on, with any parameter: url, id, size, align, alt, link.
Props to Separatista for taking the time to make a Czech translation.
And props to Mike for pitching in with suggestions.


Hi
Looks really promising!
As I understand, one can insert a template tag into the loop to display a thumbnail generated from a (the first?) image in each post.
Correct?
More precisely I’m looking for a plugin that (after inserting a tag in a template)
- generates a thumbnail from (preferably) the first image in the post
- makes the thumb clickable, to open the post (like here: http://www.dolcevita.no/umbria/)
- the post image thumbnail is generated by making a thumbnail on the fly, pulled from WP’s own thumbnails – or is a minimized display of the post image (?)
Great if you could clear this up – maybe also make a demo. It would be really useful.
Thanks,
Kjetil
There are other plugins that work like this, but it makes for slow performance. With this plugin, you can better control when and where to display the image. You just need to use the Import button first.
Yes, you can do that with this plugin.
Again, generating thumbnails on the fly makes for bad performance. If WP has a thumbnail, the plugin will use that. If not, it will display the full-sized image (you can control the size through CSS).
A demo with what? You can see the screenshots for a view of the settings page and the post box.
Thanks a lot for your explanations
regarding…
- generate a plugin from the first image: What I meant was if the thumbnail is generated automatically from the first image in the post. With the Post-thumb plugin (now outdated) the thumb is generated “on the fly” the first time the blog page is loaded. The thumb then is saved for later on the server, so the performance is only a bit slow the first time.
Automatically generating (and inserting) the thumb would also be handy since I have about 200 posts where I need this to happen (when I remove that old plugin).
- if WP has a thumbnail: I’ll just have to figure out how to do this. Also loading the full image and just display is smaller (via css) can also be slow.
- a demo: Since it is handy to see it live without installing it on a (live) site first.
Thanks again for your swift reply!
Kjetil
About the thumbnail:
I know I’ve seen a plugin similar to Post Thumb that’s still supported. I just don’t remember what it’s called.
About the demo:
It’s not like a Lightbox plugin where seeing the animation helps you decide if you like it or not.
There’s not much to see besides what’s already in the screnshots. You just have to install it and decide if it’s right for your site.
OK – I see – fine :o)
If you come to think of that plugin I would be really glad to hear about it.
kj
Hi. First of all, thanks for the plugin.
This is exactly I was looking for.
I have a question…
I got it working as expected in page but not in post.
I use WP2.8.1.
And Error message I have got:
Warning: sprintf() [function.sprintf]: Too few arguments in /home/studiomo/public_html/labs/wp-content/plugins/custom-field-images/custom-field-images.php on line 221
If you can tell me how to fix it, I’d really appriciate!
Thank you in advance.
Try this:
Open custom-field-images.php, go to line 221 and add an ‘@’before sprintf, so that it looks like this:
Thanks for the replay.
I’ve got it working.
I’ve prepend @ on original line.
Then I checked off plugin setting of Link image to post.
Either that or I have have link in custom field.
Well, it’s working now, and I learned what @ do in PHP.
Thanks!
I’ll try to send Japanese translation as soon as possible to contribute.
Ok, glad I could be of assistance. :)
Hi, I would like to suggest another feature. When I want to use CFI plugin on page where there are no pictures in the beginning of posts to import, it would be fine, if there is possibility to import first picture related to post. Or allow to check “if there is no CFI image then show the first one or nothing”.
I think the best way is to add a new parameter to the custom_field_image() template tag. It will be added in a future release.
Thanks for the suggestion.
Actually, I think this function would do the trick:
Great, thank you, I will test it. But it would be also helpfull to have simple checkbox in administration. Something like Default URL, it would be “If no CFI for post, then show first picture (thumbnail)”.
BTW: Using IE8 with your “Add a comment” field here is not user-friendly. There is nothing visible, field shrinks…
You’re right about the comment field. Thanks for the warning.
Since you switched to using Image ID, it doesn’t seem to be working. We are using WP 2.8.2 and CFI 2.0.0.1. What happens is, when we click INSERT CFI like usual, it does add the images ALT TEXT into the CFI form – but not the ID.
Any ideas? Could it be a conflict between plugins?
Possibly. Try the button after deactivating all other plugins.
Also, what browser are you using?
Turns out it was conflicting with a plugin called Scissors (here: http://stephanreiter.info/2008/10/wordpress-plugin-scissors/)
I deactivated that plugin, and the Image ID showed up and all is well.
Any ideas why? I mean… I know if you’re not familiar with that plugin it would be hard to tell, right?
Here’s a hint… it was working fine alongside Scissors before you started using Image ID’s.
I’ll see if I can make the two play nice together. Will let you know how it went.
I can’t reproduce the problem with Scissors activated. It doesn’t seem to interfere at all with the media screen where the Insert CFI button appears.
You didn’t mention what browser you’re using.
disculpen…
quise dcir dimensionar la imagen en forma automatica..
por ejemplo
100x100px
gracias
If the images are uploaded through WP, you have to configure the thumbnail size in Settings -> Media.
Otherwise, you can use CSS: max-width, max-height etc.
gracias
en la actulizacion…seria mejor un menu donde me indique.el tamaño de la imagene…
como en la version 1.7
I’m not sure which menu you’re talinkg about in version 1.7.
In version 2.0, if you set an image by ID, you can also select it’s size: ‘large’, ‘medium’etc. Then you can configure those sizes as described above.
Maybe you need a setting like “Default size”? But that would still be ‘large’, ‘medium’etc.
I’m using WordPress 2.8.2 and CFI v2.0.0.1 and am getting the error:
Parse error: parse error, unexpected T_CLASS in “[…]/wordpress/httpdocs/wp-content/plugins/custom-field-images/custom-field-images.php on line 72
I’ve deactivated all other plugins and still have the same issue. Any ideas?
Yeah, please switch to PHP5.
If you think you are using PHP5, add this line to your wp-config.php to make sure:
var_dump(PHP_VERSION);
Looks like I’m on v4. Thanks for the help!