acf-audio-video icon indicating copy to clipboard operation
acf-audio-video copied to clipboard

PHP warning when $attachment_url is an array

Open kara-todd opened this issue 6 years ago • 3 comments

I'm not sure exactly why I'm running across this in my app... but I'm getting an array passed to _get_attachment_id_from_url rather than a string.

This is predictably throwing a warning strpos() expects parameter 1 to be string, array given acf-audio-video/acf-audio-video-field.php:380

I didn't hunt down the source of the error, but just checking that the passed variable $attachment_url is indeed a string resolves the warning for me.

kara-todd avatar Mar 31 '18 01:03 kara-todd

I am experiencing this too. This is only when I try to replace a video. If the field is empty and a video is added, it works fine. The commit referenced does not resolve the issue since it does not update the field when the array comes, it deletes its content.

aleberguer avatar May 17 '18 12:05 aleberguer

I found the problem, is in this line https://github.com/ipsips/acf-audio-video/blob/b2298f5b49d23519f996f95ad0be565bf5f46697/scripts/acf-audio-video-field.js#L182

An extra '[attName]' it's being added, which is already on the input name, resulting on a name of the form: acf[field_555555][field_123123][mp4][mp4]

rolling back this line, to the previous version seems to work ok. https://github.com/ipsips/acf-audio-video/blob/b2298f5b49d23519f996f95ad0be565bf5f46697/scripts/acf-audio-video-field.js#L85

aleberguer avatar May 17 '18 16:05 aleberguer

@kara-todd, @aleberguer Try to download and install this new plugin: https://github.com/virgo79/acf-audio-video-player

virgo79 avatar Sep 14 '18 16:09 virgo79