Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplicate images after insert shortcake shortcode... #814

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions js/build/shortcode-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ var MediaController = wp.media.controller.State.extend({
menuItem.render();

this.frame.setState( 'insert' );
this.frame.uploader.uploader.uploader.init();
// This string is duplicating "Uploading images"
// This bug has appeared from fix issue https://github.com/wp-shortcake/shortcake/issues/788
//this.frame.uploader.uploader.uploader.init();
},

setActionSelect: function() {
Expand Down Expand Up @@ -407,6 +409,18 @@ $(document).ready(function(){
frame = wp.media.editor.open( editor, options );
}

// This feature fixed some bugs:
// - duplicate images while loading https://wordpress.org/support/topic/weird-conflict-shortcake-ui-arve-plugins-images-being-uploaded-multiple-times/
// - fix unclickable button, after insert shortcake shortcode https://github.com/wp-shortcake/shortcake/issues/788
// This fix on based solution "zoliszabo (@zoliszabo)", but with my changes (Fix zoliszabo has errors duplicating upload-window on each image)
// Because I have hung initialization uploader on click's event ".shortcake-add-post-element"
// ( https://github.com/zoliszabo/shortcake/commit/32097ce6989509558bbcdab5906aa43474bebef8 ).
frame.uploader.uploader.uploader.setOption(
'runtimes',
frame.uploader.uploader.uploader.getOption('runtimes'),
false
);

// Make sure to reset state when closed.
frame.once( 'close submit', function() {
frame.mediaController.reset();
Expand Down Expand Up @@ -1532,7 +1546,7 @@ var insertShortcodeList = wp.Backbone.View.extend({
this.displayShortcodes( options );

},

refresh: function( shortcodeData ) {
var options;
if ( shortcodeData instanceof Backbone.Collection ) {
Expand All @@ -1542,10 +1556,10 @@ var insertShortcodeList = wp.Backbone.View.extend({
}
this.displayShortcodes( options );
},

displayShortcodes: function(options) {
var t = this;

t.$el.find('.add-shortcode-list').html('');
t.options = {};
t.options.shortcodes = options.shortcodes;
Expand Down Expand Up @@ -1722,10 +1736,10 @@ var SearchShortcode = wp.media.view.Search.extend({
tagName: 'input',
className: 'search',
id: 'media-search-input',

initialize: function( options ) {
this.shortcodeList = options.shortcodeList;
},
},

attributes: {
type: 'search',
Expand All @@ -1743,7 +1757,7 @@ var SearchShortcode = wp.media.view.Search.extend({
this.el.value = this.model.escape('search');
return this;
},

refreshShortcodes: function( shortcodeData ) {
this.shortcodeList.refresh( shortcodeData );
},
Expand Down Expand Up @@ -1856,7 +1870,7 @@ sui.views.editAttributeSelect2Field = sui.views.editAttributeField.extend( {
render: function() {

var self = this,
defaults = {
defaults = {
multiple: false,
allowClear: false
};
Expand Down
4 changes: 3 additions & 1 deletion js/src/controllers/media-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ var MediaController = wp.media.controller.State.extend({
menuItem.render();

this.frame.setState( 'insert' );
this.frame.uploader.uploader.uploader.init();
// This string is duplicating "Uploading images"
// This bug has appeared from fix issue https://github.com/wp-shortcake/shortcake/issues/788
//this.frame.uploader.uploader.uploader.init();
},

setActionSelect: function() {
Expand Down
12 changes: 12 additions & 0 deletions js/src/shortcode-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ $(document).ready(function(){
frame = wp.media.editor.open( editor, options );
}

// This feature fixed some bugs:
// - duplicate images while loading https://wordpress.org/support/topic/weird-conflict-shortcake-ui-arve-plugins-images-being-uploaded-multiple-times/
// - fix unclickable button, after insert shortcake shortcode https://github.com/wp-shortcake/shortcake/issues/788
// This fix on based solution "zoliszabo (@zoliszabo)", but with my changes (Fix zoliszabo has errors duplicating upload-window on each image)
// Because I have hung initialization uploader on click's event ".shortcake-add-post-element"
// ( https://github.com/zoliszabo/shortcake/commit/32097ce6989509558bbcdab5906aa43474bebef8 ).
frame.uploader.uploader.uploader.setOption(
'runtimes',
frame.uploader.uploader.uploader.getOption('runtimes'),
false
);

// Make sure to reset state when closed.
frame.once( 'close submit', function() {
frame.mediaController.reset();
Expand Down