Developer's Custom Fields
[resolved] Outputting files / images (3 posts)

  1. ch8rt
    Posted 5 years ago #

    Two questions in one day. :)

    I'm trying to get attached files to output, but using the regular line of code at best just supplies an id.

    <?php echo slt_cf_field_value( 'product-image-1' ); >

    I can see in your documentation there is a type declaration for attachment. But it seems to have no effect on the above. Any pointers?

  2. Steve Taylor
    Plugin Author

    Posted 5 years ago #

    Yeah, I decided it's best to store the ID, then what you do with files on output (especially images) is more flexible. You need to look at something like:

    <?php echo wp_get_attachment_image( slt_cf_field_value( 'product-image-1' ) ); ?>

    See http://codex.wordpress.org/Function_Reference/wp_get_attachment_image and the other attachment functions listed at the end of that page.

    The "attachment" type you're looking at is probably a "box type", i.e. it says that the "box" of fields being defined is to be included on the attachment edit screens (not post or user edit screens). The "box" concept is a bit redundant for attachment and user fields, but the code started life just dealing with post edit screen meta boxes.

  3. ch8rt
    Posted 5 years ago #

    Super fast reply, thanks Steve.

    I was stuck in your plugin documentation then, rather than thinking about WP functions. :) Doh!


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Developer's Custom Fields
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic