Skip to content

Instantly share code, notes, and snippets.

@N-Molham
Created June 6, 2017 09:45
Show Gist options
  • Save N-Molham/79112f9f21d62659ef8ed0942936ba9d to your computer and use it in GitHub Desktop.
Save N-Molham/79112f9f21d62659ef8ed0942936ba9d to your computer and use it in GitHub Desktop.
Set the closest field input value to the selected file URL
// select handler
var on_file_select = function ( $button ) {
return function () {
// fetch selected file
selected_file_url = file_frame.state().get( 'selection' ).first().toJSON().url;
// set linked field input new value
$button.closest( '.acf-input' ).find( '.acf-url input[type=url]' ).val( selected_file_url ).trigger( 'change' );
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment