network-media-library icon indicating copy to clipboard operation
network-media-library copied to clipboard

Fix a bug on return format

Open ixkaito opened this issue 5 years ago • 3 comments

Network-media-library ignores the return format on the central media site.

ixkaito avatar Jun 29 '19 08:06 ixkaito

Thanks for the report. NML shouldn't need to make any changes to the return value of this function when operating on the central media site.

What's the exact issue that's occurring? Can you share a code example please?

johnbillion avatar Jun 29 '19 09:06 johnbillion

If I set "Image Object" as the Return Value for an image field, var_dump( get_field( 'image' ) ); wouldn't return an array but a string of ID (e.g. string '2058' (length=4)) on the central media site, but this returns an array (e.g. array (size=24) 'ID' => int 2058 ...) normally on sites other than the central media site.

ixkaito avatar Jun 30 '19 02:06 ixkaito

I can confirm this. The issue is that if a return format other than ID is used for a field fetched with get_field on the central media site, the following conditional won't be true and the return format won't be respected.

https://github.com/humanmade/network-media-library/blob/master/network-media-library.php#L445

joiglifberg avatar Oct 01 '19 12:10 joiglifberg

This was not the correct approach, so I'll close it. See #91

ixkaito avatar Sep 06 '22 10:09 ixkaito