WordPress.org

Plugin Directory

Changeset 1592308


Ignore:
Timestamp:
02/09/17 07:56:58 (10 months ago)
Author:
gitlost
Message:

v1.0.3

Location:
gs-only-pdf-preview/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • gs-only-pdf-preview/trunk/gs-only-pdf-preview.php

    r1592102 r1592308  
    44 * Plugin URI: https://github.com/gitlost/gs-only-pdf-preview 
    55 * Description: Uses Ghostscript directly to generate PDF previews. 
    6  * Version: 1.0.2 
     6 * Version: 1.0.3 
    77 * Author: gitlost 
    88 * Author URI: https://profiles.wordpress.org/gitlost 
     
    1717 
    1818// These need to be synced with "readme.txt". 
    19 define( 'GOPP_PLUGIN_VERSION', '1.0.2' ); // Sync also "package.json" and "language/gs-only-pdf-preview.pot". 
     19define( 'GOPP_PLUGIN_VERSION', '1.0.3' ); // Sync also "package.json" and "language/gs-only-pdf-preview.pot". 
    2020define( 'GOPP_PLUGIN_WP_AT_LEAST_VERSION', '4.7.0' ); 
    2121define( 'GOPP_PLUGIN_WP_UP_TO_VERSION', '4.7.2' ); 
     
    695695            $title = ''; // We no longer insert title tags into <img> tags, as they are redundant. 
    696696            $html = get_image_send_to_editor( $id, $caption, $title, $align, $url, $rel, $size, $alt ); 
     697            // Add a dummy srcset so that wp_make_content_images_responsive() doesn't try to use it. 
     698            $html = str_replace( '<img ', '<img srcset="" ', $html ); 
    697699        } 
    698700        return $html; 
  • gs-only-pdf-preview/trunk/js/gs-only-pdf-preview.js

    r1592102 r1592308  
    131131        var $tmpl_attachment_details, $tmpl_attachment_display_settings, $tmpl_image_details, html_before, 
    132132            html_attachment_details, 
    133             attachment_details_re = /(<# } else if \( 'image' === data\.type && data\.sizes \) { #>[\s]+<img src="{{ data\.size\.url }}" draggable="false" alt="" \/>[\s]+)(<# } else { #>)/, 
    134             attachment_details_with = '$1\n<# } else if ( data.sizes && data.sizes.thumbnail ) { #>\n<img src="{{ data.sizes.thumbnail.url }}" draggable="false" alt="" />$2', 
     133            attachment_details_re = /(<# } else if \( 'image' === data\.type && data\.sizes \) { #>\s+<img src="{{ data\.size\.url }}" draggable="false" alt="" \/>)(\s+<# } else { #>)/, 
     134            attachment_details_with = '$1\n<# } else if ( data.sizes && data.sizes.thumbnail ) { #>\n<img src="{{ data.sizes.thumbnail.url }}" draggable="false" alt="" />\n$2', 
    135135            html_attachment_display_settings, 
    136             attachment_display_settings_re = /(<# if \( data\.userSettings \) { #>[\s]+data-user-setting="imgsize"[\s]+<# } #>>)([\s]+<#)/, 
    137             attachment_display_settings_with = '$1\n<# if ( \'application\' === data.type ) { #>\n<option value="">\n' + gopp_plugin_params.document_link_only + '\n</option>\n<# } #>\n$2', 
     136            attachment_display_settings_re = /<option value="post">\n\s+<# if \( data\.model\.canEmbed \) { #>\n[^\n]+\n[^\n]+\n\s+<\/option>/, 
     137            attachment_display_settings_with = '<# if ( \'application\' !== data.type ) { #>\n$&\n<# } #>\n', 
     138            attachment_display_settings2_re = /(<# if \( data\.userSettings \) { #>\s+data-user-setting="imgsize"\s+<# } #>>)(\s+<#)/, 
     139            attachment_display_settings2_with = '$1\n<# if ( \'application\' === data.type ) { #>\n<option value="">\n' + gopp_plugin_params.document_link_only + '\n</option>\n<# } #>\n$2', 
    138140            html_image_details, 
    139141            image_details_re = /(<# if \( data\.attachment && window\.imageEdit)( \) { #>)/, 
     
    155157                } 
    156158 
    157                 // #39618 Adds "Document Link Only" option to Size select of Attachment Details. 
     159                // #39618 Removes "Attachment" option from Link To select of Attachment Details. 
    158160                html_before = $tmpl_attachment_display_settings.html(); 
    159161                html_attachment_display_settings = html_before.replace( attachment_display_settings_re, attachment_display_settings_with ); 
     162                if ( html_before === html_attachment_display_settings ) { 
     163                    return false; 
     164                } 
     165                // #39618 Adds "Document Link Only" option to Size select of Attachment Details. 
     166                html_before = html_attachment_display_settings; 
     167                html_attachment_display_settings = html_before.replace( attachment_display_settings2_re, attachment_display_settings2_with ); 
    160168                if ( html_before === html_attachment_display_settings ) { 
    161169                    return false; 
     
    255263    gopp_plugin.patch_39630 = function () { 
    256264        var $tmpl_attachment = $( '#tmpl-attachment' ), html_before, html_attachment, 
    257             attachment_re = /(<# } else if \( data\.sizes && )data\.sizes\.medium( \) { #>[\s]+<img src="{{ )data\.sizes\.medium(\.url }}" class="thumbnail" draggable="false" alt="" \/>[\s]+<# } else { #>)/, 
     265            attachment_re = /(<# } else if \( data\.sizes && )data\.sizes\.medium( \) { #>\s+<img src="{{ )data\.sizes\.medium(\.url }}" class="thumbnail" draggable="false" alt="" \/>\s+<# } else { #>)/, 
    258266            attachment_with = '$1( data.sizes.thumbnail || data.sizes.medium )$2( data.sizes.thumbnail || data.sizes.medium )$3'; 
    259267 
  • gs-only-pdf-preview/trunk/js/gs-only-pdf-preview.min.js

    r1592102 r1592308  
    1 /*! gs-only-pdf-preview 1.0.2 2017-02-08 */ 
    2 var gopp_plugin=gopp_plugin||{};!function(a){"use strict";gopp_plugin.regen_pdf_preview=function(){var b=a("#gopp_regen_pdf_previews"),c=a(".gopp_regen_pdf_previews_form",b);b.length&&a('input[type="submit"]',c).click(function(d){var e,f,g=a(this),h=a(".notice, .updated",b),i=a(gopp_plugin_params.please_wait_msg),j=parseInt(a("#poll_cnt",c).val(),10),k=a("#poll_nonce",c).val();g.hide(),a(".gopp_regen_pdf_previews_form_hide",b).hide(),h.hide(),a("h1",b).first().after(i),e=a("#gopp_progress",b),f=function(){a.post(ajaxurl,{action:"gopp_poll_regen_pdf_previews",cnt:j,poll_nonce:k},function(a){a&&a.msg&&e.html(a.msg),setTimeout(f,1e3*gopp_plugin_params.val.poll_interval)},"json")},a.browser&&a.browser.safari?(d.preventDefault(),a(".spinner",i).removeClass("is-active"),g.unbind("click"),setTimeout(function(){g.click()},0)):setTimeout(f,1e3*gopp_plugin_params.val.poll_interval)})},gopp_plugin.media_row_action=function(b,c,d){var e=a(b.target),f=e.parents(".row-actions").first(),g=e.next();return a(".gopp_response",f.parent()).remove(),g.addClass("is-active"),a.post({url:ajaxurl,data:{action:"gopp_media_row_action",id:c,nonce:d},dataType:"json",error:function(b,c,d){var e;g.removeClass("is-active"),e='<div class="notice error gopp_response"><p>'+gopp_plugin_params.action_not_available+" ("+d+")</p></div>",f.after(a(e))},success:function(b){g.removeClass("is-active"),a(".gopp_response",f.parent()).remove(),b?(b.error?f.after(a('<div class="notice error gopp_response"><p>'+b.error+"</p></div>")):b.msg&&f.after(a('<div class="notice updated gopp_response"><p>'+b.msg+"</p></div>")),b.img&&a(".has-media-icon .media-icon",f.parent()).html(b.img)):f.after(a('<div class="notice error gopp_response"><p>'+gopp_plugin_params.action_not_available+"</p></div>"))},timeout:1e3*gopp_plugin_params.val.min_time_limit}),!1},gopp_plugin.upload=function(){a("#doaction, #doaction2").click(function(b){a('select[name^="action"]').each(function(){var c,d;"gopp_regen_pdf_previews"===a(this).val()&&(c=a(b.target),d=a.makeArray(a('#the-list input[name="media[]"]:checked').map(function(){return this.value})),d.length?(a(".spinner",c.parent()).remove(),a(gopp_plugin_params.spinner).insertAfter(c)):(b.preventDefault(),a(".gopp_none",c.parent()).remove(),a(gopp_plugin_params.no_items_selected_msg).insertAfter(c).fadeOut(1e3,function(){a(this).remove()})))})})},gopp_plugin.post=function(){var b,c,d,e,f,g,h,i=/(<# } else if \( 'image' === data\.type && data\.sizes \) { #>[\s]+<img src="{{ data\.size\.url }}" draggable="false" alt="" \/>[\s]+)(<# } else { #>)/,j='$1\n<# } else if ( data.sizes && data.sizes.thumbnail ) { #>\n<img src="{{ data.sizes.thumbnail.url }}" draggable="false" alt="" />$2',k=/(<# if \( data\.userSettings \) { #>[\s]+data-user-setting="imgsize"[\s]+<# } #>>)([\s]+<#)/,l="$1\n<# if ( 'application' === data.type ) { #>\n<option value=\"\">\n"+gopp_plugin_params.document_link_only+"\n</option>\n<# } #>\n$2",m=/(<# if \( data\.attachment && window\.imageEdit)( \) { #>)/,n="$1 && 'image' === data.type $2";return wp.media&&wp.media.editor&&wp.media.editor.send&&"function"==typeof wp.media.editor.send.attachment&&(b=a("#tmpl-attachment-details"),c=a("#tmpl-attachment-display-settings"),d=a("#tmpl-image-details"),b.length&&c.length&&d.length)?(e=b.html(),f=e.replace(i,j),e===f?!1:(e=c.html(),g=e.replace(k,l),e===g?!1:(e=d.html(),h=e.replace(m,n),e===h?!1:!1===gopp_plugin.patch_39630()?!1:(b.html(f),c.html(g),d.html(h),wp.media.editor.send.attachment=gopp_plugin.media_editor_send_attachment,!0)))):!1},gopp_plugin.media_editor_send_attachment=function(a,b){var c,d,e=b.caption;return wp.media.view.settings.captions||delete b.caption,a=wp.media.string.props(a,b),c={id:b.id,post_content:b.description,post_excerpt:e},a.linkUrl&&(c.url=a.linkUrl),"image"===b.type?(d=wp.media.string.image(a),_.each({align:"align",size:"image-size",alt:"image_alt"},function(b,d){a[d]&&(c[b]=a[d])})):"video"===b.type?d=wp.media.string.video(a,b):"audio"===b.type?d=wp.media.string.audio(a,b):(d=wp.media.string.link(a),c.post_title=a.title,"application"===b.type&&"pdf"===b.subtype&&_.each({align:"align",size:"image-size"},function(b,d){a[d]&&(c[b]=a[d])})),wp.media.post("send-attachment-to-editor",{nonce:wp.media.view.settings.nonce.sendToEditor,attachment:c,html:d,post_id:wp.media.view.settings.post.id})},gopp_plugin.patch_39630=function(){var b,c,d=a("#tmpl-attachment"),e=/(<# } else if \( data\.sizes && )data\.sizes\.medium( \) { #>[\s]+<img src="{{ )data\.sizes\.medium(\.url }}" class="thumbnail" draggable="false" alt="" \/>[\s]+<# } else { #>)/,f="$1( data.sizes.thumbnail || data.sizes.medium )$2( data.sizes.thumbnail || data.sizes.medium )$3";return d.length?(b=d.html(),c=b.replace(e,f),b===c?!1:(d.html(c),!0)):!1},a(function(){gopp_plugin_params&&gopp_plugin_params.val&&(gopp_plugin_params.val.is_regen_pdf_preview?gopp_plugin.regen_pdf_preview():gopp_plugin_params.val.is_upload?(gopp_plugin.upload(),gopp_plugin.patch_39630()):gopp_plugin_params.val.is_post&&gopp_plugin.post())})}(jQuery); 
     1/*! gs-only-pdf-preview 1.0.3 2017-02-09 */ 
     2var gopp_plugin=gopp_plugin||{};!function(a){"use strict";gopp_plugin.regen_pdf_preview=function(){var b=a("#gopp_regen_pdf_previews"),c=a(".gopp_regen_pdf_previews_form",b);b.length&&a('input[type="submit"]',c).click(function(d){var e,f,g=a(this),h=a(".notice, .updated",b),i=a(gopp_plugin_params.please_wait_msg),j=parseInt(a("#poll_cnt",c).val(),10),k=a("#poll_nonce",c).val();g.hide(),a(".gopp_regen_pdf_previews_form_hide",b).hide(),h.hide(),a("h1",b).first().after(i),e=a("#gopp_progress",b),f=function(){a.post(ajaxurl,{action:"gopp_poll_regen_pdf_previews",cnt:j,poll_nonce:k},function(a){a&&a.msg&&e.html(a.msg),setTimeout(f,1e3*gopp_plugin_params.val.poll_interval)},"json")},a.browser&&a.browser.safari?(d.preventDefault(),a(".spinner",i).removeClass("is-active"),g.unbind("click"),setTimeout(function(){g.click()},0)):setTimeout(f,1e3*gopp_plugin_params.val.poll_interval)})},gopp_plugin.media_row_action=function(b,c,d){var e=a(b.target),f=e.parents(".row-actions").first(),g=e.next();return a(".gopp_response",f.parent()).remove(),g.addClass("is-active"),a.post({url:ajaxurl,data:{action:"gopp_media_row_action",id:c,nonce:d},dataType:"json",error:function(b,c,d){var e;g.removeClass("is-active"),e='<div class="notice error gopp_response"><p>'+gopp_plugin_params.action_not_available+" ("+d+")</p></div>",f.after(a(e))},success:function(b){g.removeClass("is-active"),a(".gopp_response",f.parent()).remove(),b?(b.error?f.after(a('<div class="notice error gopp_response"><p>'+b.error+"</p></div>")):b.msg&&f.after(a('<div class="notice updated gopp_response"><p>'+b.msg+"</p></div>")),b.img&&a(".has-media-icon .media-icon",f.parent()).html(b.img)):f.after(a('<div class="notice error gopp_response"><p>'+gopp_plugin_params.action_not_available+"</p></div>"))},timeout:1e3*gopp_plugin_params.val.min_time_limit}),!1},gopp_plugin.upload=function(){a("#doaction, #doaction2").click(function(b){a('select[name^="action"]').each(function(){var c,d;"gopp_regen_pdf_previews"===a(this).val()&&(c=a(b.target),d=a.makeArray(a('#the-list input[name="media[]"]:checked').map(function(){return this.value})),d.length?(a(".spinner",c.parent()).remove(),a(gopp_plugin_params.spinner).insertAfter(c)):(b.preventDefault(),a(".gopp_none",c.parent()).remove(),a(gopp_plugin_params.no_items_selected_msg).insertAfter(c).fadeOut(1e3,function(){a(this).remove()})))})})},gopp_plugin.post=function(){var b,c,d,e,f,g,h,i=/(<# } else if \( 'image' === data\.type && data\.sizes \) { #>\s+<img src="{{ data\.size\.url }}" draggable="false" alt="" \/>)(\s+<# } else { #>)/,j='$1\n<# } else if ( data.sizes && data.sizes.thumbnail ) { #>\n<img src="{{ data.sizes.thumbnail.url }}" draggable="false" alt="" />\n$2',k=/<option value="post">\n\s+<# if \( data\.model\.canEmbed \) { #>\n[^\n]+\n[^\n]+\n\s+<\/option>/,l="<# if ( 'application' !== data.type ) { #>\n$&\n<# } #>\n",m=/(<# if \( data\.userSettings \) { #>\s+data-user-setting="imgsize"\s+<# } #>>)(\s+<#)/,n="$1\n<# if ( 'application' === data.type ) { #>\n<option value=\"\">\n"+gopp_plugin_params.document_link_only+"\n</option>\n<# } #>\n$2",o=/(<# if \( data\.attachment && window\.imageEdit)( \) { #>)/,p="$1 && 'image' === data.type $2";return wp.media&&wp.media.editor&&wp.media.editor.send&&"function"==typeof wp.media.editor.send.attachment&&(b=a("#tmpl-attachment-details"),c=a("#tmpl-attachment-display-settings"),d=a("#tmpl-image-details"),b.length&&c.length&&d.length)?(e=b.html(),f=e.replace(i,j),e===f?!1:(e=c.html(),g=e.replace(k,l),e===g?!1:(e=g,g=e.replace(m,n),e===g?!1:(e=d.html(),h=e.replace(o,p),e===h?!1:!1===gopp_plugin.patch_39630()?!1:(b.html(f),c.html(g),d.html(h),wp.media.editor.send.attachment=gopp_plugin.media_editor_send_attachment,!0))))):!1},gopp_plugin.media_editor_send_attachment=function(a,b){var c,d,e=b.caption;return wp.media.view.settings.captions||delete b.caption,a=wp.media.string.props(a,b),c={id:b.id,post_content:b.description,post_excerpt:e},a.linkUrl&&(c.url=a.linkUrl),"image"===b.type?(d=wp.media.string.image(a),_.each({align:"align",size:"image-size",alt:"image_alt"},function(b,d){a[d]&&(c[b]=a[d])})):"video"===b.type?d=wp.media.string.video(a,b):"audio"===b.type?d=wp.media.string.audio(a,b):(d=wp.media.string.link(a),c.post_title=a.title,"application"===b.type&&"pdf"===b.subtype&&_.each({align:"align",size:"image-size"},function(b,d){a[d]&&(c[b]=a[d])})),wp.media.post("send-attachment-to-editor",{nonce:wp.media.view.settings.nonce.sendToEditor,attachment:c,html:d,post_id:wp.media.view.settings.post.id})},gopp_plugin.patch_39630=function(){var b,c,d=a("#tmpl-attachment"),e=/(<# } else if \( data\.sizes && )data\.sizes\.medium( \) { #>\s+<img src="{{ )data\.sizes\.medium(\.url }}" class="thumbnail" draggable="false" alt="" \/>\s+<# } else { #>)/,f="$1( data.sizes.thumbnail || data.sizes.medium )$2( data.sizes.thumbnail || data.sizes.medium )$3";return d.length?(b=d.html(),c=b.replace(e,f),b===c?!1:(d.html(c),!0)):!1},a(function(){gopp_plugin_params&&gopp_plugin_params.val&&(gopp_plugin_params.val.is_regen_pdf_preview?gopp_plugin.regen_pdf_preview():gopp_plugin_params.val.is_upload?(gopp_plugin.upload(),gopp_plugin.patch_39630()):gopp_plugin_params.val.is_post&&gopp_plugin.post())})}(jQuery); 
  • gs-only-pdf-preview/trunk/languages/gs-only-pdf-preview-fr_FR.po

    r1592102 r1592308  
    33msgid "" 
    44msgstr "" 
    5 "Project-Id-Version: GS Only PDF Preview 1.0.2\n" 
     5"Project-Id-Version: GS Only PDF Preview 1.0.3\n" 
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/gs-only-pdf-" 
    77"preview\n" 
    8 "POT-Creation-Date: 2017-02-08 21:11+0000\n" 
    9 "PO-Revision-Date: 2017-02-08 21:11+0000\n" 
     8"POT-Creation-Date: 2017-02-09 07:40+0000\n" 
     9"PO-Revision-Date: 2017-02-09 07:40+0000\n" 
    1010"Last-Translator: gitlost <gitlost@gitlostbonger.com>\n" 
    1111"Language-Team: \n" 
  • gs-only-pdf-preview/trunk/languages/gs-only-pdf-preview.pot

    r1592102 r1592308  
    33msgid "" 
    44msgstr "" 
    5 "Project-Id-Version: GS Only PDF Preview 1.0.2\n" 
     5"Project-Id-Version: GS Only PDF Preview 1.0.3\n" 
    66"Report-Msgid-Bugs-To: " 
    77"https://wordpress.org/support/plugin/gs-only-pdf-preview\n" 
  • gs-only-pdf-preview/trunk/readme.txt

    r1592102 r1592308  
    44Requires at least: 4.7.0 
    55Tested up to: 4.7.2 
    6 Stable tag: 1.0.2 
     6Stable tag: 1.0.3 
    77License: GPLv2 or later 
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html 
     
    5656= Patches = 
    5757 
    58 As a bonus version 1.0.2 patches WordPress to allow linking to the preview image in "Add Media" when editing a post ([#39618 Insert PDF Thumbnail into Editor](https://core.trac.wordpress.org/ticket/39618)). Also patches [#39630 PDF Thumbnails in Media Library Don't Fall Back to Full Size](https://core.trac.wordpress.org/ticket/39630). 
     58As a bonus version 1.0.2+ patches WordPress to allow linking to the preview image in "Add Media" when editing a post ([#39618 Insert PDF Thumbnail into Editor](https://core.trac.wordpress.org/ticket/39618)). Also patches [#39630 PDF Thumbnails in Media Library Don't Fall Back to Full Size](https://core.trac.wordpress.org/ticket/39630). 
    5959 
    6060= And = 
     
    130130== Changelog == 
    131131 
     132= 1.0.3 (9 Feb 2017) = 
     133* Add dummy srcset on linked preview thumbnail so that wp_make_content_images_responsive() ignores it. 
     134* Remove Attachment from Link To for pdfs. 
     135 
    132136= 1.0.2 (8 Feb 2017) = 
    133137* Don't overwrite existing JPEGs with same name as preview. 
     
    148152== Upgrade Notice == 
    149153 
     154= 1.0.3 = 
     155Avoids PHP warning on linked pdf thumbnails. 
     156 
    150157= 1.0.2 = 
    151158Doesn't overwrite existing JPEGs with same name as preview. Removes existing preview thumbnails on regeneration. 
Note: See TracChangeset for help on using the changeset viewer.