WordPress.org

Ready to get started?Download WordPress

Forums

Custom Field Template
[resolved] Media picker not inserting (19 posts)

  1. difreo
    Member
    Posted 3 years ago #

    Media picker is not working. Here is the code
    [foto]
    label = Foto
    type = file
    relation = true
    mediaPicker = true

    It opens up the media library dialog box. After clicking "use this" it dissapears but no value is assigned to the field.

    http://wordpress.org/extend/plugins/custom-field-template/

  2. rpetersnmt
    Member
    Posted 3 years ago #

    I'm seeing the same issue...but only with a custom post type...works fine for stock "posts".

    Hmm...did you find the culprit/reason this is the case? Are you using with a Custom Post Type by chance? This works for me withe stock "Post":

    [Banner Image]
    type = file
    relation = true
    mediaPicker = true
    mediaLibrary = true
    label = Banner (background) Override

  3. difreo
    Member
    Posted 3 years ago #

    You're right rpetersnmt! It's not working with the custom post type only. With standard posts it's working fine. I looked at the link of the "select by media picker" and it's doesn't have the id of the post
    media-upload.php?type=image&tab=library&post_id=&TB_iframe=true&tab=library&cftid=file_upload0_0
    Anyone got idea how to solve this issue?

  4. difreo
    Member
    Posted 3 years ago #

    update... it gets the id, so it must be something with the jquery functions?

  5. rpetersnmt
    Member
    Posted 3 years ago #

    Yeah..it felt like a JS issue, but no errors on my end. Anybody else noticed this? We could consider posting in some other places too...I'm hoping the CPT author might see this and be able to quickly catch what's going on.

  6. rpetersnmt
    Member
    Posted 3 years ago #

    Any more news on this front? Difreo, did you happen to find a workaround? I think this is affecting "Pages" as well....from what I/we can tell, only Posts appear to be properly working with the Media Picker option.

  7. difreo
    Member
    Posted 3 years ago #

    Nothing new. I was unable to find the source of this issue :(

  8. Hiroaki Miyashita
    Member
    Plugin Author

    Posted 3 years ago #

    I tried it out but it seems working well.
    Are there any JavaScript errors? Please try to disable other plugins except the custom field template.

  9. difreo
    Member
    Posted 3 years ago #

    Did You tried it with custom post types? I've disabled all plugins but CFT and it does not work. Double, triple checked it. WordPress doesn't throw any errors.

  10. sanderbontje
    Member
    Posted 3 years ago #

    I am having the same issue as well. Works ok in normal posts and pages, but not on a custom post type. Disabled all plugins except for qTranslate.

  11. difreo
    Member
    Posted 3 years ago #

    Hello Hiroaki, did You find the solution to this issue? It seems like more people have this problem.

  12. JimmyO
    Member
    Posted 3 years ago #

    Exactly the same problem. Have been using CFT with media picker on normal posts with no problems. I had to create a custom post type today, but clicking on the "use this" link in the media window doesn't add a value to the field. Only on custom field types.

  13. bbloye
    Member
    Posted 3 years ago #

    Just to add my voice, I'm having the same problem, too.

    The problem only seems to affect post types added manually using register_post_type in functions.php, though. I didn't have the same problem with post types added using the 'Custom Post Type UI' plugin on another site, so perhaps it's worth trying this (or another) plugin if you are having problems.

    This makes me wonder if there is some property that is being set by the plugin that needs to be set in the register_post_type function for the Media Picker to work.

  14. sanderbontje
    Member
    Posted 3 years ago #

    I'm using register_post_type from within functions.php to set up my custom post type too. Just updated to CFT 1.8.7, no change.

  15. difreo
    Member
    Posted 3 years ago #

    Victory at last! ;) Thanks bbloye. It was the problem with registering the post type. I've checked the 'Custom Post Type UI' plugin and it turns out that You have to set higher priority for add_action. In your functions.php:
    instead of add_action('init', 'register_post_type');
    should be add_action('init', 'register_post_type', 0);
    Can anyone confirm this?

  16. sanderbontje
    Member
    Posted 3 years ago #

    Solution confirmed! A big thanks to difreo and bbloye!

  17. bbloye
    Member
    Posted 3 years ago #

    Well done, difreo. Added the 0 to my init function and I can now add images with the Media Picker.

    For reference, my code is as follows (register_post_type arguments omitted for clarity):

    add_action('init', 'banner_register', 0);
    
    function banner_register() {
      register_post_type(…);
    }
  18. rpetersnmt
    Member
    Posted 3 years ago #

    Aw h*ll yes....nice work difreo and bbloye! Real well done. Special thanks to you guys. :)

  19. seanjacob
    Member
    Posted 3 years ago #

    Is this going to be a update to fix this problem? I don't even have anything in my function to get my custom fields and I am having the same problem...

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic