• Resolved Cees van Dongen

    (@ceesvandongen)


    Hi Matt,
    I was trying to use your plugin to create a custom field inwhich I could store the URL of an attachement.
    I have used for this the field type ‘file upload’ and selected the return value File URL.

    The custum field is perfectly showing in editing the post, and I can select a file from the media lib. The problem is that the Save action results in saving the ID of the attachment instead of the file URL.

    Could please look at this bug?!

    rgrds, Cees van Dongen

Viewing 4 replies - 1 through 4 (of 4 total)
  • Is this a bug or is this how WP saves image links in post_meta? I’m grappling with the same issue and trying to solve it via resolving the URL of the image’s post ID or thumbnail.

    • This reply was modified 8 years, 1 month ago by starapple.

    @ceesvandongen,

    My solution if retrieving the image URL and displaying the image is the problem:

    $photo_id = get_post_meta($post->ID, 'passport_photo', true);
    $photo_url = wp_get_attachment_url($photo_id); ?>
    <img src="<?php echo $photo_url;?>" />
    <?php

    This works within the loop on my theme’s single.php.

    HTH

    • This reply was modified 8 years, 1 month ago by starapple.
    • This reply was modified 8 years, 1 month ago by starapple.
    Plugin Author Matt Gibbs

    (@mgibbs189)

    Guys, please read the docs: https://customfieldsuite.com/field-types/file.html

    CFS ALWAYS saves the attachment ID. To grab the URL, you must use the CFS()->get() method.

    • This reply was modified 8 years, 1 month ago by Matt Gibbs.

    Thanks @mgibbs189. Holding my head in shame. I did not read the docs. I had been using WP’s the_meta(); to display the entire collection of fields on a page and saw the file upload returned as “passport_photo: 46” as part of a bulleted list, rather than the image I expected to see.

    This solved the problem of showing the photo:
    ~
    ?>
    get( ‘passport_photo’ );?>” />
    <?php ~

    Thanks again.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘File upload to save URL is not working’ is closed to new replies.