Support

Account

Home Forums ACF PRO Extend format_value / missing ACF on attachments

Helping

Extend format_value / missing ACF on attachments

  • Heya,

    Currently we have two ACF values on attachments, when using: get_fields(); for a specific post these ACF values don’t get added.

    As example, I have a post with ACF image fields when getting this post and all of its fields (get_fields($post_id)) it does not add the attachment custom values.

    Is there a way of adding this info without having to hack into the image field / format_value function.

    Ideal would be if I could add a filter that always gets all fields for each post and attachment and add this to the output.

    Cheers,

    Mark

    The current output:

    
    [0] => Array
        (
            [ID] => 433
            [id] => 433
            [alt] => 
            [title] => IMG_3499-3
            [caption] => 
            [description] => 
            [mime_type] => image/jpeg
            [type] => image
            [url] => /wp-content/uploads/2014/08/IMG_3499-3.jpg
            [width] => 1920
            [height] => 1280
            [sizes] => Array
                (
                    [thumbnail] => /wp-content/uploads/2014/08/IMG_3499-3-150x150.jpg
                    [thumbnail-width] => 150
                    [thumbnail-height] => 150
                    [medium] => /wp-content/uploads/2014/08/IMG_3499-3-640x426.jpg
                    [medium-width] => 640
                    [medium-height] => 426
                    [large] => /wp-content/uploads/2014/08/IMG_3499-3-1024x682.jpg
                    [large-width] => 640
                    [large-height] => 426
                )
        )
    
  • Hi @marksmits,

    I would recommend you make use of the object return type for the image fields, this would help in fetching the image array.

    You can also checkout the get_field_objects() function which also returns an array of custom field objects for a specific page / post.

    You can check it out here: http://www.advancedcustomfields.com/resources/get_field_objects/

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Extend format_value / missing ACF on attachments’ is closed to new replies.