From f0af56e8e060944dec2137e53a4485a2321e35ad Mon Sep 17 00:00:00 2001 From: Amin Amanpour Date: Sun, 25 Feb 2018 08:13:49 +0330 Subject: [PATCH] Update class-option-gallery.php --- lib/class-option-gallery.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/class-option-gallery.php b/lib/class-option-gallery.php index 127c808b..8de8e04a 100644 --- a/lib/class-option-gallery.php +++ b/lib/class-option-gallery.php @@ -145,7 +145,20 @@ function tfUploadOptionCenterImage($this) { library: { type: 'image' }, button : { text : '' } }); + frame.on('open',function() { + + var selection = frame.state().get('selection'); + if(_input.val()!="") + { + var ids = _input.val().split(','); + ids.forEach(function(id) { + var attachment = wp.media.attachment(id); + attachment.fetch(); + selection.add( attachment ? [ attachment ] : [] ); + }); + } + }); // Get the url when done. frame.on('select', function() { var selection = frame.state().get('selection');