This version adds the option to use the first attached image to a post as the displayed image.

Also, if you use get_custom_field_image() with format=html, you will get the same values that would be used by custom_field_image(). This allows you to format the image however you want.

The Insert CFI button should work with Internet Explorer again.

Comments (60)

  • SuzT says:

    Hi, in a prior comment response you mention
    ====
    In version 2.0 of CFI, you will be able to store the image ID, instead of the URL. Having the image ID, you can get the path using get_attached_file();
    ===
    Now that it is out.. What is the code that is needed to get just the url path of the image to use with timthumb.

    Here is the code that I a need to complete to pull the cfi image.

     &lt;img src=&quot;/scripts/timthumb.php?src=&amp;w=172&amp;h=139&amp;zc=1" alt="" /&gt;</a>

    Thank you,
    Suz

    • SuzT says:

      sorry that should have been html I think

      < img src="/scripts/timthumb.php?src=&w=172&h=139&zc=1" alt="" />

      corrected my email address also

    • scribu says:
      $cfi = get_custom_field_image('', '', 'object');
       
      echo $cfi->url;
  • elvis says:

    Hi, how do i change the default alignment? i thought there used to be an option for it?
    if not an option, is it possible to code it when you insert into template.. (I think you wrote it on the description page but the code doesn’t show up in the html!)

    thanks
    elvis

  • Erica says:

    Is there any way to add the custom field to the sidebar as opposed to including an image within the post?

    I am looking for a plugin to post ad images in specific post for the sidebar.

    Is this possible with this plugin, and if not, where can I find a plugin that can do this for the sidebar within a post.

    You can check out the site at http//theblvdmag.com

  • Ionut says:

    Salut
    Folosind pluginul tau poti adauga mai multe cfi-uri la o pagina?

  • Jim Krill says:

    Hi,

    I’m trying to transfer a wordpress site that uses CFI to a different directory (from a staging directory to a live directory) and change all the references in the database, but when I load the page in the live directory, CFI stops working on most images but not all images?

    Is there a technique for changing urls in the database when moving from one location to another for CFI?

    Thanks.

    • Jim Krill says:

      It appears that some of my CFI’s are using ID’s – and those are working. The ones that were using URL’s are not. But the strange thing is that on the previous directory (which was a subdomain) they were working (the URL’s) but now they are not.

      Any ideas?

      • scribu says:

        They’re probably not working because the wp-content directory has changed.

        You could try this:
        -export images
        -use the Search and Replace plugin
        -import images

  • rILLEST says:

    Hi,

    I’m using the plugin with “slimbox-plugin” to show images. Is it possible to display a link back to the post in the “description” field in Lighbox mode?
    By “description” I mean using the title attr of the image tag which I found that I can access in your plugins settings “Extra link attributes” by adding

    title=""

    Thanks for a great plugin!

    • scribu says:

      The right way to set the title attr is with the Alt. Text field for each image.

      • rILLEST says:

        Sorry, I meant the title attr of the link (as this is picked up by the slimbox-plugin and shown as description), I would like to automatically have a link back to the post there if possible..

        • scribu says:

          You’ll have to build the tag manually. Put this in The Loop:

          <?php 
          $img = get_custom_field_image('', '', 'object');
          $post_link = sprintf("< a href='%s' title=''>%s</a>",
            get_permalink($post->ID), get_the_title());
           
          printf("< a href='%s' title='%s'">< img src='' /></a>",
            $img->link, esc_html($post_link), $img->url);
  • Hello, is there a way to have multiple images instead of one only. I would like to use this for a kind of picture gallery.

    • scribu says:

      No, I’m afraid there isn’t.

      • toure says:

        Thanks.
        But any idea how could I get one?
        What about using an array that will look for the different image values for a same key?
        I have been looking around and don’t wanna use any gallery template. I just want something easy to use

        • scribu says:

          You can use the [gallery] shortcode already built into WP – just attach images to a post and insert the shortcode in the post content.

          • toure says:

            Thanks for helping here, but can I get more precision please.

            • scribu says:

              When writing a post, upload images using the WP interface. You will see a gallery tab where you can set the order of the images.

              Then all you have to do is add [gallery] anywhere in the post.

              For detailed options, see Gallery Shortcode

  • Son Nguyen says:

    Thanks for your nice plugin!

    Please add a function which allow custom template, such as $before_html, $after_html, $a_class, $img_class, …

    Thank you!

    • scribu says:

      There already is:

      $img = get_custom_field_image('', '', 'object');
       
      echo "< li>< a href='$img->link' class='whatever'>< img src='$img->url' /></a></li>";
  • tosho says:

    You actually need PHP 5.1.0 or above to use this plugin.

    array_intersect_key() is used, which requires (PHP 5 >= 5.1.0)

    http://us2.php.net/manual/en/function.array-intersect-key.php

    and also, what does

    Trimite-mi mail când apare un comentariu nou.

    mean in english? :)

    • scribu says:

      You’re right. I’ll fix that soon.

      That text means “Subscribe to comments” (it’s translated now).

      Thanks for the comment :)

  • Katootje says:

    Is there a way to show the caption with the image?

  • btz says:

    hi scribu, i`ve just tried to instla cfi on final version of wp (2.8.4.) and this is the message i get:
    Plugin could not be activated because it triggered a fatal error.
    Fatal error: Class ’scbOptions’ not found in /hsphere/local/home/ottoo/curtici.net/wp-content/plugins/custom-field-images/custom-field-images.php on line 40

    • scribu says:

      Make sure that you have the file /scb/Options.php

      If you do, please add this line to wp-config.php and tell me what you get:

      var_dump(function_exists('spl_autoload_register'));

      Also, do you use any other plugin of mine?

      • Sally says:

        I’m also having a fatal error problem:

        Parse error: syntax error, unexpected T_CLASS in /…/wp-content/plugins/custom-field-images/custom-field-images.php on line 75

        I don’t have any of your other plugins, but I do have a few others running, and I’m using the Atahualpa theme.

        I have the scb/Options.php file, and with that line added I get:
        bool(false)

        And when I try to activate the plugin:

        Warning: Cannot modify header information – headers already sent by (output started at /…/wp-config.php:79) in /…/wp-includes/pluggable.php on line 865

        Hope you can help! Thanks!

  • Dejan says:

    Why i cant insert CFI in Popular post section? In new posts CFI works fine but in popular dont show it… i use word press 2.7

  • Dejan says:

    i dont know really, i got it with theme, i think it is plug in. it hase own function in functions php file. also i tried plugin sharthis, it also wont work in popular post section

  • Dejan says:

    Ok, and can u tell me why CFI some times resize image to thumbnail and sometimes just crop it?

    • scribu says:

      It’s probably because it can’t find the thumbs for some images (those that aren’t hosted on your site). The easiest way to fix this is to add a max-width attribute in your style.css file.

  • Jason says:

    I’m using WP 2.8.4. I cannot seem to get an image to show up in the post teaser when I choose an image and click on “INSERT CFI”. The only way images show up is if I have “If there is no CFI for a post, use the first attachment to that post instead” check marked enabled. This presents a problem because the images are 300px width and too large for my site. How might I correct this issue?

    • scribu says:

      You can either shrink the images through CSS or set ‘thumbnail’ as the default size in the settings page of the plugin.

      • Jason says:

        Thank you for responding so quickly. I had the setting set at thumbnail, yet it still shows a very large image. Any idea why an image doesn’t show using “INSERT CFI”?

        • scribu says:

          Do you have the “Custom Field Image” box open when clicking “Insert CFI”? What does it look like after clicking?

  • Kristina says:

    I am assigning an image to a post & wanting to pull it full size for one place (main image of that post in the header)
    and also as a thumbnail (for ‘recent posts’ area)

    can you tell me what I need to put in the custom_field_image( ) to get the thumbnail – I already have the full size working)

    thank you

  • Separatista says:

    Hi, I tried to use this plugin with WPMU 2.8.4a, but there is no “Insert CFI” button on media pages and also Default size does not work (as I tried to set all sizes, only Medium size is shown when there is no CFI fulfilled and I want to show first attachment). Thank you for your help…

    • scribu says:

      Yeah, the problem is that I can’t easily tell which attachments are images and which aren’t. And even if I took the time to figure out a way, I would probably have to do it all over again in WP 2.9.

      The default size will work in the next version.

  • Paul says:

    Hello. This plugin is the closest thing to what I’m trying to find. However, I would like a link there that instead inserts the image url into an actual custom field. Did you look into this when designing this plugin? And can that be a future option? Maybe you can refer me to another plugin that has that feature right now?

    Also, I’m having a problem with the “insert CFI” link taking about 30 seconds to show up.

    • scribu says:

      Earlier versions of this plugin stored the URL in a separate field. As for the button, I hope I can make it faster with WP 2.9.