Socket
Socket
Sign inDemoInstall

wp-media-picker

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.7.1 to 0.7.2

2

bower.json
{
"name": "wp-media-picker",
"version": "0.7.1",
"version": "0.7.2",
"description": "This jQuery plugin for WordPress can be used to transform an input field into a flexible and compatible media field with attachment selection and preview.",

@@ -5,0 +5,0 @@ "main": [

{
"name": "wp-media-picker",
"version": "0.7.1",
"version": "0.7.2",
"description": "This jQuery plugin for WordPress can be used to transform an input field into a flexible and compatible media field with attachment selection and preview.",

@@ -5,0 +5,0 @@ "keywords": [

/*
* WP Media Picker - version 0.7.1
* WP Media Picker - version 0.7.2
*

@@ -233,13 +233,13 @@ * Felix Arntz <felix-arntz@leaves-and-love.net>

self.content_id = 'wp-mediapicker-content-' + self.element.attr( 'id' );
self._content_id = 'wp-mediapicker-content-' + self.element.attr( 'id' );
self.element.hide().wrap( '<div class="wp-mediapicker-container" />' );
self.wrap = self.element.parent();
self.open_button = $( '<button type="button" class="wp-mediapicker-open-button button" />' ).insertAfter( self.element );
self.remove_button = $( '<button type="button" class="wp-mediapicker-remove-button button-link button-link-delete" />' ).hide().insertAfter( self.open_button ).text( self.options.label_remove );
self.content_wrap = $( '<div class="wp-mediapicker-content-wrap" />' ).insertAfter( self.remove_button );
self.content = $( '<div class="wp-mediapicker-content" />' ).appendTo( self.content_wrap ).attr( 'id', self.content_id );
self._wrap = self.element.parent();
self._open_button = $( '<button type="button" class="wp-mediapicker-open-button button" />' ).insertAfter( self.element );
self._remove_button = $( '<button type="button" class="wp-mediapicker-remove-button button-link button-link-delete" />' ).hide().insertAfter( self._open_button ).text( self.options.label_remove );
self._content_wrap = $( '<div class="wp-mediapicker-content-wrap" />' ).insertAfter( self._remove_button );
self._content = $( '<div class="wp-mediapicker-content" />' ).appendTo( self._content_wrap ).attr( 'id', self._content_id );
self.frame = new MediaPickerFrame({
self._frame = new MediaPickerFrame({
title: self.options.label_modal,

@@ -274,4 +274,4 @@ buttonText: self.options.label_button,

self.frame.on( 'insert', function() {
var selection = self.frame.state().get( 'selection' );
self._frame.on( 'insert', function() {
var selection = self._frame.state().get( 'selection' );
var attachments = selection.models.map( function( model ) {

@@ -287,5 +287,5 @@ return _.extend( {}, model.toJSON() );

self.open_button.on( 'click', function() {
var selection = self.frame.state( 'insert' ).get( 'selection' );
selection.reset( self.attachment ? [ self.attachment ] : [] );
self._open_button.on( 'click', function() {
var selection = self._frame.state( 'insert' ).get( 'selection' );
selection.reset( self._attachment ? [ self._attachment ] : [] );

@@ -295,3 +295,3 @@ self.open();

self.remove_button.on( 'click', function() {
self._remove_button.on( 'click', function() {
self._setAttachment( null );

@@ -313,6 +313,6 @@ });

self.attachment = attachment;
self._attachment = attachment;
self.open_button.text( self.options.label_replace );
self.remove_button.show();
self._open_button.text( self.options.label_replace );
self._remove_button.show();

@@ -353,8 +353,8 @@ var preview_content = '';

if ( 0 <= preview_content.search( '<img ' ) ) {
self.content.addClass( 'size-auto' );
self._content.addClass( 'size-auto' );
} else {
self.content.removeClass( 'size-auto' );
self._content.removeClass( 'size-auto' );
}
self.content.show().html( preview_content );
self._content.show().html( preview_content );
},

@@ -372,7 +372,7 @@

self.attachment = null;
self._attachment = null;
self.open_button.text( self.options.label_add );
self.remove_button.hide();
self.content.hide().empty().removeClass( 'size-auto' );
self._open_button.text( self.options.label_add );
self._remove_button.hide();
self._content.hide().empty().removeClass( 'size-auto' );
},

@@ -388,3 +388,3 @@

_getAttachment: function() {
return this.attachment;
return this._attachment;
},

@@ -405,3 +405,3 @@

_setAttachment: function( attachment ) {
var noChange = ( attachment && this.attachment && attachment.id === this.attachment.id ) || ( ! attachment && ! this.attachment );
var noChange = ( attachment && this._attachment && attachment.id === this._attachment.id ) || ( ! attachment && ! this._attachment );

@@ -456,3 +456,3 @@ if ( ! attachment ) {

_getValue: function() {
if ( ! this.attachment ) {
if ( ! this._attachment ) {
return '';

@@ -462,6 +462,6 @@ }

if ( 'url' === this.options.store ) {
return this.attachment.url;
return this._attachment.url;
}
return this.attachment.id;
return this._attachment.id;
},

@@ -503,6 +503,6 @@

open: function() {
wp.media.frame = this.frame;
wp.media.frame = this._frame;
this.frame.open();
this.frame.$el.find( '.media-frame-menu .media-menu-item.active' ).focus();
this._frame.open();
this._frame.$el.find( '.media-frame-menu .media-menu-item.active' ).focus();
},

@@ -518,3 +518,3 @@

close: function() {
this.frame.close();
this._frame.close();
},

@@ -564,3 +564,3 @@

frame: function() {
return this.frame;
return this._frame;
}

@@ -567,0 +567,0 @@ };

/*!
* WP Media Picker - version 0.7.1
* WP Media Picker - version 0.7.2
*
* Felix Arntz <felix-arntz@leaves-and-love.net>
*/
!function(a,r,o){var e,t,i;if(void 0===r||void 0===r.media)return a.fn.wpMediaPicker=function(){return this},console.error("WP Media not found");e=r.media.view.MediaFrame.Select,t=e.extend({initialize:function(){o.defaults(this.options,{query:{},multiple:!1,editable:!0,filterable:"all",searchable:!0,displaySettings:!1,displayUserSettings:!1,editing:!1,state:"insert",metadata:{}}),e.prototype.initialize.apply(this,arguments)},createStates:function(){this.states.add([new r.media.controller.Library({id:"insert",title:this.options.title,selection:this.options.selection,priority:20,toolbar:"main-insert",filterable:this.options.filterable,searchable:this.options.searchable,library:r.media.query(this.options.query),multiple:this.options.multiple,editable:this.options.editable,displaySettings:this.options.displaySettings,displayUserSettings:this.options.displayUserSettings}),new r.media.controller.EditImage({model:this.options.editImage})])},bindHandlers:function(){e.prototype.bindHandlers.apply(this,arguments),this.on("toolbar:create:main-insert",this.createToolbar,this),this.on("content:render:edit-image",this.renderEditImageContent,this),this.on("toolbar:render:main-insert",this.renderMainInsertToolbar,this)},renderEditImageContent:function(){var e=new r.media.view.EditImage({controller:this,model:this.state().get("image")}).render();this.content.set(e),e.loadEditor()},renderMainInsertToolbar:function(e){var t=this;e.set("insert",{style:"primary",priority:80,text:t.options.buttonText,requires:{selection:!0},click:function(){t.close(),t.state().trigger("insert",t.state().get("selection")).reset()}})}}),i={options:{store:"id",query:{},multiple:!1,filterable:"all",searchable:!0,editable:!1,displaySettings:!1,displayUserSettings:!1,change:!1,clear:!1,label_add:r.media.view.l10n.addMedia,label_replace:r.media.view.l10n.replace,label_remove:r.media.view.l10n.remove,label_modal:r.media.view.l10n.addMedia,label_button:r.media.view.l10n.addMedia},_create:function(){var e=this;a.extend(e.options,e.element.data()),e.options.query&&e.options.query.post_mime_type&&(e.options.query.type=e.options.query.post_mime_type,delete e.options.query.post_mime_type),e.content_id="wp-mediapicker-content-"+e.element.attr("id"),e.element.hide().wrap('<div class="wp-mediapicker-container" />'),e.wrap=e.element.parent(),e.open_button=a('<button type="button" class="wp-mediapicker-open-button button" />').insertAfter(e.element),e.remove_button=a('<button type="button" class="wp-mediapicker-remove-button button-link button-link-delete" />').hide().insertAfter(e.open_button).text(e.options.label_remove),e.content_wrap=a('<div class="wp-mediapicker-content-wrap" />').insertAfter(e.remove_button),e.content=a('<div class="wp-mediapicker-content" />').appendTo(e.content_wrap).attr("id",e.content_id),e.frame=new t({title:e.options.label_modal,buttonText:e.options.label_button,frame:"select",state:"insert",selection:new r.media.model.Selection([],{multiple:e.options.multiple}),query:e.options.query,multiple:e.options.multiple,filterable:e.options.filterable,searchable:e.options.searchable,editable:e.options.editable}),e._setValue(e.element.val()),e._addListeners()},_addListeners:function(){var n=this;n.frame.on("insert",function(){var e=n.frame.state().get("selection"),t=e.models.map(function(e){return o.extend({},e.toJSON())}),i=o.extend({},e.first().toJSON());n._setAttachment(i),a(document).trigger("wpMediaPicker.insert",[t,n])}),n.open_button.on("click",function(){n.frame.state("insert").get("selection").reset(n.attachment?[n.attachment]:[]),n.open()}),n.remove_button.on("click",function(){n._setAttachment(null)})},_createContent:function(e){var t=this;t.attachment=e,t.open_button.text(t.options.label_replace),t.remove_button.show();var i="";if("video"===e.type){var n="";e.image&&e.image.src!==e.icon&&(n=e.image.src),i+='<video class="wp-video-shortcode" preload="metadata"'+(n?' poster="'+n+'"':"")+' controls><source type="'+e.mime+'" src="'+e.url+'" /></video>'}else if("audio"===e.type)e.image&&e.image.src&&e.image.src!==e.icon?i+='<img class="wp-audio-cover" src="'+e.image.src+'" alt="'+e.filename+'" />':i+='<div class="mime-type-icon"><img src="'+e.icon+'" /><span>'+e.filename+"</span></div>",i+='<audio class="wp-audio-shortcode" width="100%" preload="none" controls><source type="'+e.mime+'" src="'+e.url+'" /></audio>';else{var a="image"===e.type?e.url:void 0;e.sizes&&(e.sizes.large?a=e.sizes.large.url:e.sizes.full&&(a=e.sizes.full.url)),i+=a?'<img src="'+a+'" alt="'+e.alt+'" />':'<div class="mime-type-icon"><img src="'+e.icon+'" /><span>'+e.filename+"</span></div>"}0<=i.search("<img ")?t.content.addClass("size-auto"):t.content.removeClass("size-auto"),t.content.show().html(i)},_resetContent:function(){var e=this;e.attachment=null,e.open_button.text(e.options.label_add),e.remove_button.hide(),e.content.hide().empty().removeClass("size-auto")},_getAttachment:function(){return this.attachment},_setAttachment:function(e){var t=e&&this.attachment&&e.id===this.attachment.id||!e&&!this.attachment;if(!e){if(this._resetContent(),t)return;return this.element.val(null),this.element.trigger("change"),"function"==typeof this.options.clear&&this.options.clear.call(this),void a(document).trigger("wpMediaPicker.updateField",[null,this])}this._createContent(e),t||("url"===this.options.store?this.element.val(e.url):this.element.val(e.id),this.element.trigger("change"),"function"==typeof this.options.change&&this.options.change.call(this),a(document).trigger("wpMediaPicker.updateField",[e,this]))},_getValue:function(){return this.attachment?"url"===this.options.store?this.attachment.url:this.attachment.id:""},_setValue:function(e){var t,i,n,a,o,s=this;t=e,i=s.options.store,n=function(e){s._setAttachment(e)},a=function(){s._setAttachment(null)},t?(o="url"===i?{action:"get-attachment-by-url",url:t}:{action:"get-attachment",id:parseInt(t,10)},r.media.ajax({type:"POST",data:o,success:n,error:a})):a()},open:function(){r.media.frame=this.frame,this.frame.open(),this.frame.$el.find(".media-frame-menu .media-menu-item.active").focus()},close:function(){this.frame.close()},attachment:function(e){if(void 0===e)return this._getAttachment();this._setAttachment(e)},value:function(e){if(void 0===e)return this._getValue();this._setValue(e)},frame:function(){return this.frame}},a.widget("wp.wpMediaPicker",i)}(jQuery,wp,_);
!function(a,r,o){var e,t,i;if(void 0===r||void 0===r.media)return a.fn.wpMediaPicker=function(){return this},console.error("WP Media not found");e=r.media.view.MediaFrame.Select,t=e.extend({initialize:function(){o.defaults(this.options,{query:{},multiple:!1,editable:!0,filterable:"all",searchable:!0,displaySettings:!1,displayUserSettings:!1,editing:!1,state:"insert",metadata:{}}),e.prototype.initialize.apply(this,arguments)},createStates:function(){this.states.add([new r.media.controller.Library({id:"insert",title:this.options.title,selection:this.options.selection,priority:20,toolbar:"main-insert",filterable:this.options.filterable,searchable:this.options.searchable,library:r.media.query(this.options.query),multiple:this.options.multiple,editable:this.options.editable,displaySettings:this.options.displaySettings,displayUserSettings:this.options.displayUserSettings}),new r.media.controller.EditImage({model:this.options.editImage})])},bindHandlers:function(){e.prototype.bindHandlers.apply(this,arguments),this.on("toolbar:create:main-insert",this.createToolbar,this),this.on("content:render:edit-image",this.renderEditImageContent,this),this.on("toolbar:render:main-insert",this.renderMainInsertToolbar,this)},renderEditImageContent:function(){var e=new r.media.view.EditImage({controller:this,model:this.state().get("image")}).render();this.content.set(e),e.loadEditor()},renderMainInsertToolbar:function(e){var t=this;e.set("insert",{style:"primary",priority:80,text:t.options.buttonText,requires:{selection:!0},click:function(){t.close(),t.state().trigger("insert",t.state().get("selection")).reset()}})}}),i={options:{store:"id",query:{},multiple:!1,filterable:"all",searchable:!0,editable:!1,displaySettings:!1,displayUserSettings:!1,change:!1,clear:!1,label_add:r.media.view.l10n.addMedia,label_replace:r.media.view.l10n.replace,label_remove:r.media.view.l10n.remove,label_modal:r.media.view.l10n.addMedia,label_button:r.media.view.l10n.addMedia},_create:function(){var e=this;a.extend(e.options,e.element.data()),e.options.query&&e.options.query.post_mime_type&&(e.options.query.type=e.options.query.post_mime_type,delete e.options.query.post_mime_type),e._content_id="wp-mediapicker-content-"+e.element.attr("id"),e.element.hide().wrap('<div class="wp-mediapicker-container" />'),e._wrap=e.element.parent(),e._open_button=a('<button type="button" class="wp-mediapicker-open-button button" />').insertAfter(e.element),e._remove_button=a('<button type="button" class="wp-mediapicker-remove-button button-link button-link-delete" />').hide().insertAfter(e._open_button).text(e.options.label_remove),e._content_wrap=a('<div class="wp-mediapicker-content-wrap" />').insertAfter(e._remove_button),e._content=a('<div class="wp-mediapicker-content" />').appendTo(e._content_wrap).attr("id",e._content_id),e._frame=new t({title:e.options.label_modal,buttonText:e.options.label_button,frame:"select",state:"insert",selection:new r.media.model.Selection([],{multiple:e.options.multiple}),query:e.options.query,multiple:e.options.multiple,filterable:e.options.filterable,searchable:e.options.searchable,editable:e.options.editable}),e._setValue(e.element.val()),e._addListeners()},_addListeners:function(){var n=this;n._frame.on("insert",function(){var e=n._frame.state().get("selection"),t=e.models.map(function(e){return o.extend({},e.toJSON())}),i=o.extend({},e.first().toJSON());n._setAttachment(i),a(document).trigger("wpMediaPicker.insert",[t,n])}),n._open_button.on("click",function(){n._frame.state("insert").get("selection").reset(n._attachment?[n._attachment]:[]),n.open()}),n._remove_button.on("click",function(){n._setAttachment(null)})},_createContent:function(e){var t=this;t._attachment=e,t._open_button.text(t.options.label_replace),t._remove_button.show();var i="";if("video"===e.type){var n="";e.image&&e.image.src!==e.icon&&(n=e.image.src),i+='<video class="wp-video-shortcode" preload="metadata"'+(n?' poster="'+n+'"':"")+' controls><source type="'+e.mime+'" src="'+e.url+'" /></video>'}else if("audio"===e.type)e.image&&e.image.src&&e.image.src!==e.icon?i+='<img class="wp-audio-cover" src="'+e.image.src+'" alt="'+e.filename+'" />':i+='<div class="mime-type-icon"><img src="'+e.icon+'" /><span>'+e.filename+"</span></div>",i+='<audio class="wp-audio-shortcode" width="100%" preload="none" controls><source type="'+e.mime+'" src="'+e.url+'" /></audio>';else{var a="image"===e.type?e.url:void 0;e.sizes&&(e.sizes.large?a=e.sizes.large.url:e.sizes.full&&(a=e.sizes.full.url)),i+=a?'<img src="'+a+'" alt="'+e.alt+'" />':'<div class="mime-type-icon"><img src="'+e.icon+'" /><span>'+e.filename+"</span></div>"}0<=i.search("<img ")?t._content.addClass("size-auto"):t._content.removeClass("size-auto"),t._content.show().html(i)},_resetContent:function(){var e=this;e._attachment=null,e._open_button.text(e.options.label_add),e._remove_button.hide(),e._content.hide().empty().removeClass("size-auto")},_getAttachment:function(){return this._attachment},_setAttachment:function(e){var t=e&&this._attachment&&e.id===this._attachment.id||!e&&!this._attachment;if(!e){if(this._resetContent(),t)return;return this.element.val(null),this.element.trigger("change"),"function"==typeof this.options.clear&&this.options.clear.call(this),void a(document).trigger("wpMediaPicker.updateField",[null,this])}this._createContent(e),t||("url"===this.options.store?this.element.val(e.url):this.element.val(e.id),this.element.trigger("change"),"function"==typeof this.options.change&&this.options.change.call(this),a(document).trigger("wpMediaPicker.updateField",[e,this]))},_getValue:function(){return this._attachment?"url"===this.options.store?this._attachment.url:this._attachment.id:""},_setValue:function(e){var t,i,n,a,o,s=this;t=e,i=s.options.store,n=function(e){s._setAttachment(e)},a=function(){s._setAttachment(null)},t?(o="url"===i?{action:"get-attachment-by-url",url:t}:{action:"get-attachment",id:parseInt(t,10)},r.media.ajax({type:"POST",data:o,success:n,error:a})):a()},open:function(){r.media.frame=this._frame,this._frame.open(),this._frame.$el.find(".media-frame-menu .media-menu-item.active").focus()},close:function(){this._frame.close()},attachment:function(e){if(void 0===e)return this._getAttachment();this._setAttachment(e)},value:function(e){if(void 0===e)return this._getValue();this._setValue(e)},frame:function(){return this._frame}},a.widget("wp.wpMediaPicker",i)}(jQuery,wp,_);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc