bonny / WordPress-Simple-Fields

WordPress plugin that extend Custom Fields to include textareas, WYSIWYG-editor, files, attachments, well basically anything
http://wordpress.org/extend/plugins/simple-fields/
88 stars 23 forks source link

Pages with simple field of type file but no file returns weird response #94

Closed frompton closed 10 years ago

frompton commented 10 years ago

I have a simple fields field of type file to save custom images to a page, but if I save the pages without selecting an image it seems to still try to attach an image but failing. Expected response of

$custom_bg = simple_fields_value('page_background_image', $post->ID);

would be an empty array, but instead I get this

Array
(
    [id] => 0
    [is_image] => 
    [url] => 
    [mime] => 
    [link] => Array
        (
            [full] => Bilaga saknas
            [thumbnail] => Bilaga saknas
            [medium] => Bilaga saknas
            [large] => Bilaga saknas
            [post-thumbnail] => Bilaga saknas
            [author-small] => Bilaga saknas
            [author-medium] => Bilaga saknas
            [books-small] => Bilaga saknas
            [books-medium] => Bilaga saknas
            [coworker-small] => Bilaga saknas
        )

    [image] => Array
        (
            [full] => 
            [thumbnail] => 
            [medium] => 
            [large] => 
            [post-thumbnail] => 
            [author-small] => 
            [author-medium] => 
            [books-small] => 
            [books-medium] => 
            [coworker-small] => 
        )

    [image_src] => Array
        (
            [full] => 
            [thumbnail] => 
            [medium] => 
            [large] => 
            [post-thumbnail] => 
            [author-small] => 
            [author-medium] => 
            [books-small] => 
            [books-medium] => 
            [coworker-small] => 
        )

    [metadata] => 
    [post] => WP_Post Object
        (
            [ID] => 280
            [post_author] => 1
            [post_date] => 2013-09-03 09:39:45
            [post_date_gmt] => 2013-09-03 07:39:45
            [post_content] => 
            [post_title] => Författare
            [post_excerpt] => 
            [post_status] => publish
            [comment_status] => open
            [ping_status] => open
            [post_password] => 
            [post_name] => forfattare
            [to_ping] => 
            [pinged] => 
            [post_modified] => 2013-09-18 10:36:56
            [post_modified_gmt] => 2013-09-18 08:36:56
            [post_content_filtered] => 
            [post_parent] => 23
            [guid] => http://sets.ep/?page_id=280
            [menu_order] => 0
            [post_type] => page
            [post_mime_type] => 
            [comment_count] => 0
            [filter] => raw
            [format_content] => 
        )

)

However, if I select an image, save the page and then click clear on the image and resave the page it goes back to returning an empty array. Subsequent saves without an image will reintroduce the bug.