WordPress.org

Forums

[resolved] [Plugin: Custom Field Template] how do i display the image or file? (7 posts)

  1. bruzed
    Member
    Posted 3 years ago #

    one of my custom fields is to display an image. the upload seems to work fine:

    [Picture]
    type=file
    relation=true
    class=file
    multiple=true

    the code i'm using to display all the other fields is below. this is obviously wrong. please help.


    <?php
    $block = get_post_meta($post->ID, 'Picture');
    foreach(($block) as $blocks) {
    echo $blocks;
    }
    ?>

    thanks in advance!

  2. hiroshikun
    Member
    Posted 3 years ago #

    i have the same problem,
    i search on the db and in the values
    of the custom fields
    i found that the attachment id is stored on the
    field, but i don't know how use the id to get the picture
    from the database

    if there is a way to get the picture by id a function to
    get the picture can do the work

    but this part is a mistery for me

  3. Hiroaki Miyashita
    Member
    Posted 3 years ago #

    There are several functions in order to display the image. This is an example.

    Template Content

    [thumbnail_id]
    type = file
    relation = true

    In the loop of the theme files like index.php, single.php, etc:

    <?php
    $thumbnail_id = get_post_meta($post->ID, 'thumbnail_id', true);
    echo wp_get_attachment_image($thumbnail_id, 'thumbnail');
    ?>

    I hope this will help you.

  4. bruzed
    Member
    Posted 3 years ago #

    thanks hiroaki that works perfectly!

  5. Arturo emilio
    Member
    Posted 3 years ago #

    Isit possible to get the value from wp_get_attachment_image($thumbnail_id, 'thumbnail');

    and save it in a custom field?

    Actually file type only save a number and i need the uri.

    regards

  6. Matt_NY
    Member
    Posted 3 years ago #

    how to get multiple thumbnails?

    and link them to a large thumbnail.

  7. illuminateddesigns
    Member
    Posted 2 years ago #

    I'd also like to know how to get multiple images to display...

Topic Closed

This topic has been closed to new replies.

About this Topic