Video's are not saved
Closed this issue · 4 comments
Unfortunately the plugin doesn't work anymore with the latest version of ACF. File preview is showing. But when publishing a post, after save the file is gone from the field type.
Additional information:
ACF Pro v: 5.5.9
Wordpress v: 4.7.2
Video is uploaded and saved in media library.
When selecting the video and publish the video is not saved in DB.
In DB field is also empty. I use PHP to add ACF fields to posttype.
The field itself is stored in DB. But empty value.
I think I resolved issue. Problem was in Javascript when rewriting hidden field based on input.
With new ACF name field is setup differently. If you have time maybe you can check? but this works for me now!
In javascript acf-audio-video-field.js __getInputName function needs rewrite.
Before (line from line 86)
__getInputName: function __getInputName() {
var inputName = this.$inputContainer.children(':first').attr('name').split('][');
if (inputName[inputName.length - 1].indexOf('field') == 0) return inputName.join('][');
inputName.splice(inputName.length - 1, 1);
return inputName.join('][') + ']';
},
After update
__getInputName: function __getInputName() {
var inputName = this.$inputContainer.children(':first').attr('name').split('][');
return inputName;
},
This fix no longer seems to work.
The previous code works only for the first selection. After saving the post for the first time, there is no way to change the selected media or to empty the field.
After investigating a bit, I've found that the hidden input that is used for storing the value into the database was altered during the media selection.
Using the following code, everything seems work fine.
__getInputName: function __getInputName() {
var key = this.$field.data('key');
var inputName = 'acf['+key+']';
return inputName;
},