WordPress.org

Plugin Directory

Changeset 1638565


Ignore:
Timestamp:
04/16/17 14:27:44 (7 months ago)
Author:
gitlost
Message:

v1.0.5

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

Legend:

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

    r1594582 r1638565  
    44 * Plugin URI: https://github.com/gitlost/gs-only-pdf-preview 
    55 * Description: Uses Ghostscript directly to generate PDF previews. 
    6  * Version: 1.0.4 
     6 * Version: 1.0.5 
    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.4' ); // Sync also "package.json" and "language/gs-only-pdf-preview.pot". 
     19define( 'GOPP_PLUGIN_VERSION', '1.0.5' ); // Sync also "package.json" and "language/gs-only-pdf-preview.pot". 
    2020define( 'GOPP_PLUGIN_WP_AT_LEAST_VERSION', '4.7.0' ); 
    21 define( 'GOPP_PLUGIN_WP_UP_TO_VERSION', '4.7.2' ); 
     21define( 'GOPP_PLUGIN_WP_UP_TO_VERSION', '4.7.3' ); 
    2222 
    2323define( 'GOPP_REGEN_PDF_PREVIEWS_SLUG', 'gopp-regen-pdf-previews' ); 
     
    4444 
    4545        if ( is_admin() ) { 
    46             if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) { 
     46            if ( ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { 
    4747                add_action( 'admin_init', array( __CLASS__, 'admin_init' ) ); 
    48                 add_action( 'admin_menu', array( __CLASS__, 'admin_menu' ) ); 
    4948                add_action( 'admin_enqueue_scripts', array( __CLASS__, 'admin_enqueue_scripts' ) ); 
    5049 
    51                 add_filter( 'bulk_actions-upload', array( __CLASS__, 'bulk_actions_upload' ) ); 
    52                 add_filter( 'handle_bulk_actions-upload', array( __CLASS__, 'handle_bulk_actions_upload' ), 10, 3 ); 
    53                 add_filter( 'removable_query_args', array( __CLASS__, 'removable_query_args' ) ); 
    54  
    55                 add_action( 'current_screen', array( __CLASS__, 'current_screen' ) ); 
    56                 add_action( 'media_row_actions', array( __CLASS__, 'media_row_actions' ), 100, 3 ); // Add after (most) others due to spinner. 
     50                if ( current_user_can( self::$cap ) ) { 
     51                    add_action( 'admin_menu', array( __CLASS__, 'admin_menu' ) ); 
     52                    add_filter( 'bulk_actions-upload', array( __CLASS__, 'bulk_actions_upload' ) ); 
     53                    add_filter( 'handle_bulk_actions-upload', array( __CLASS__, 'handle_bulk_actions_upload' ), 10, 3 ); 
     54                    add_filter( 'removable_query_args', array( __CLASS__, 'removable_query_args' ) ); 
     55                    add_action( 'current_screen', array( __CLASS__, 'current_screen' ) ); 
     56                    add_filter( 'media_row_actions', array( __CLASS__, 'media_row_actions' ), 100, 3 ); // Add after (most) others due to spinner. 
     57                } 
    5758            } else { 
    5859                add_filter( 'media_send_to_editor', array( __CLASS__, 'media_send_to_editor' ), 10, 3 ); 
    59             } 
    60             add_action( 'wp_ajax_gopp_media_row_action', array( __CLASS__, 'gopp_media_row_action' ) ); 
    61             add_action( 'wp_ajax_gopp_poll_regen_pdf_previews', array( __CLASS__,  'gopp_poll_regen_pdf_previews' ) ); 
     60 
     61                if ( current_user_can( self::$cap ) ) { 
     62                    add_action( 'wp_ajax_gopp_media_row_action', array( __CLASS__, 'gopp_media_row_action' ) ); 
     63                    add_action( 'wp_ajax_gopp_poll_regen_pdf_previews', array( __CLASS__,  'gopp_poll_regen_pdf_previews' ) ); 
     64                } 
     65            } 
    6266        } 
    6367    } 
     
    8892        if ( ! function_exists( 'exec' ) ) { 
    8993            deactivate_plugins( $plugin_basename ); 
    90             if ( in_array( 'exec', array_map( 'trim', explode( ',', strtolower( ini_get( 'disable_functions' ) ) ) ), true ) ) { 
     94            $ini_get = ini_get( 'disable_functions' ); 
     95            if ( $ini_get && in_array( 'exec', array_map( 'trim', explode( ',', strtolower( $ini_get ) ) ), true ) ) { 
    9196                $msg = sprintf( 
    9297                    /* translators: %s: url to admin plugins page. */ 
     
    9499                    esc_url( self_admin_url( 'plugins.php' ) ) 
    95100                ); 
     101            } elseif ( $suhosin_disabled_msg = self::suhosin_disabled_msg() ) { 
     102                $msg = $suhosin_disabled_msg; 
    96103            } else { 
    97104                $msg = sprintf( 
     
    104111        } 
    105112 
    106         // If the (somewhat outdated) suhosin extension is loaded, then need to check its function blacklist also, as it doesn't reflect in function_exists(). 
    107         // Theoretically should first check whether the function whitelist exists and whether exec() is not in it, as it overrides the blacklist, but it's unlikely to be used. 
    108         if ( extension_loaded( 'suhosin' ) && in_array( 'exec', array_map( 'trim', explode( ',', strtolower( ini_get( 'suhosin.executor.func.blacklist' ) ) ) ), true ) ) { 
     113        // Apparently if the suhosin extension is installed, disabled functions may not be reflected in function_exists(). 
     114        if ( $suhosin_disabled_msg = self::suhosin_disabled_msg() ) { 
    109115            deactivate_plugins( $plugin_basename ); 
    110             $msg = sprintf( 
    111                 /* translators: %s: url to admin plugins page. */ 
    112                 __( 'The plugin "GS Only PDF Preview" cannot be activated as it relies on the PHP function <code>exec</code>, which has been disabled on your system via the suhosin extension directive <code>suhosin.executor.func.blacklist</code>. <a href="%s">Return to Plugins page.</a>', 'gs-only-pdf-preview' ), 
    113                 esc_url( self_admin_url( 'plugins.php' ) ) 
    114             ); 
    115             wp_die( $msg ); 
     116            wp_die( $suhosin_disabled_msg ); 
    116117        } 
    117118 
     
    128129 
    129130        global $wp_version; 
    130         $stripped_wp_version = substr( $wp_version, 0, strspn( $wp_version, '0123456789.' ) ); // Remove any trailing date stuff. 
     131        $stripped_wp_version = substr( $wp_version, 0, strspn( $wp_version, '0123456789.' ) ); // Remove any trailing stuff. 
    131132        if ( preg_match( '/^[0-9]+\.[0-9]+$/', $stripped_wp_version ) ) { 
    132133            $stripped_wp_version .= '.0'; // Make WP version x.y.z compat. 
     
    161162        GOPP_Image_Editor_GS::clear(); 
    162163 
    163         // Check if Ghostscript available. 
    164         if ( ! GOPP_Image_Editor_GS::test( array() ) ) { 
    165             $admin_notices[] = array( 'warning', __( '<strong>Warning: no Ghostscript!</strong> The plugin "GS Only PDF Preview" cannot determine the server location of your Ghostscript executable.', 'gs-only-pdf-preview' ) ); 
    166         } 
    167  
    168         if ( $admin_notices ) { 
    169             set_transient( 'gopp_plugin_admin_notices', $admin_notices, 5 * MINUTE_IN_SECONDS ); 
    170         } 
     164        // Warn if Ghostscript not available. 
     165        self::warn_if_no_gs( $admin_notices ); 
     166    } 
     167 
     168    /** 
     169     * Helper to check if suhosin extension has disabled exec(). 
     170     */ 
     171    static function suhosin_disabled_msg() { 
     172        if ( extension_loaded( 'suhosin' ) || extension_loaded( 'suhosin7' ) ) { 
     173            // Whitelist overrides blacklist according to doc https://suhosin.org/stories/configuration.html#suhosin.executor.func.whitelist 
     174            $directive = 'suhosin.executor.func.whitelist'; 
     175            $ini_get = ini_get( $directive ); 
     176            if ( $ini_get ) { 
     177                // Good luck getting WP to work if you use this! 
     178                if ( in_array( 'exec', array_map( 'trim', explode( ',', strtolower( $ini_get ) ) ), true ) ) { 
     179                    return false; 
     180                } 
     181                $msg = sprintf( 
     182                    /* translators: %1$s: name of suhosin extension directive; %2$s: url to admin plugins page. */ 
     183                    __( 'The plugin "GS Only PDF Preview" cannot be activated as it relies on the PHP function <code>exec</code>, which has been disabled on your system via the suhosin extension directive <code>%1$s</code>. <a href="%2$s">Return to Plugins page.</a>', 'gs-only-pdf-preview' ), 
     184                    $directive, esc_url( self_admin_url( 'plugins.php' ) ) 
     185                ); 
     186                return $msg; 
     187            } 
     188            $directive = 'suhosin.executor.func.blacklist'; 
     189            $ini_get = ini_get( $directive ); 
     190            if ( $ini_get && in_array( 'exec', array_map( 'trim', explode( ',', strtolower( $ini_get ) ) ), true ) ) { 
     191                $msg = sprintf( 
     192                    /* translators: %1$s: name of suhosin extension directive; %2$s: url to admin plugins page. */ 
     193                    __( 'The plugin "GS Only PDF Preview" cannot be activated as it relies on the PHP function <code>exec</code>, which has been disabled on your system via the suhosin extension directive <code>%1$s</code>. <a href="%2$s">Return to Plugins page.</a>', 'gs-only-pdf-preview' ), 
     194                    $directive, esc_url( self_admin_url( 'plugins.php' ) ) 
     195                ); 
     196                return $msg; 
     197            } 
     198        } 
     199        return false; 
    171200    } 
    172201 
     
    180209            } 
    181210            require dirname( __FILE__ ) . '/includes/class-gopp-image-editor-gs.php'; 
     211        } 
     212    } 
     213 
     214    /** 
     215     * Helper to check if Ghostscript available. 
     216     */ 
     217    static function check_have_gs( $path = null ) { 
     218        $args = array( 'mime_type' => 'application/pdf' ); 
     219        if ( null !== $path ) { 
     220            $args['path'] = $path; 
     221        } 
     222        self::load_gopp_image_editor_gs(); 
     223        return GOPP_Image_Editor_GS::test( $args ); 
     224    } 
     225 
     226    /** 
     227     * Helper to add warning admin notice if Ghostscript not available. 
     228     */ 
     229    static function warn_if_no_gs( $admin_notices = array() ) { 
     230        if ( ! self::check_have_gs() ) { 
     231            $admin_notices[] = array( 'warning', __( '<strong>Warning: no Ghostscript!</strong> The plugin "GS Only PDF Preview" cannot determine the server location of your Ghostscript executable.', 'gs-only-pdf-preview' ) ); 
     232        } 
     233        if ( $admin_notices ) { 
     234            set_transient( 'gopp_plugin_admin_notices', $admin_notices, 5 * MINUTE_IN_SECONDS ); 
    182235        } 
    183236    } 
     
    289342 
    290343    /** 
    291      * Called on 'admin_menu' action. 
     344     * Called on 'admin_menu' action for users with cap. 
    292345     * Adds the "Regen. PDF Previews" administration tool. 
    293346     */ 
     
    307360     */ 
    308361    static function load_regen_pdf_previews() { 
    309         if ( ! current_user_can( self::$cap ) ) { 
    310             wp_die( __( 'Sorry, you are not allowed to access this page.', 'gs-only-pdf-preview' ) ); 
    311         } 
    312  
    313         if ( ! empty( $_REQUEST[GOPP_REGEN_PDF_PREVIEWS_SLUG] ) ) { 
     362        if ( ! current_user_can( self::$cap ) ) { // Double-check cap. 
     363            wp_die( __( 'Sorry, you are not allowed to access this page.', 'gs-only-pdf-preview' ), '', array( 'response' => 403 ) ); 
     364        } 
     365 
     366        if ( empty( $_REQUEST[GOPP_REGEN_PDF_PREVIEWS_SLUG] ) ) { 
     367            // Warn if Ghostscript not available. 
     368            self::warn_if_no_gs(); 
     369        } else { 
    314370 
    315371            check_admin_referer( GOPP_REGEN_PDF_PREVIEWS_SLUG ); 
     
    334390     */ 
    335391    static function do_regen_pdf_previews( $ids, $check_mime_type = false, $do_transient = true ) { 
    336         static $upload_dir = null, $basedir = null; 
    337392 
    338393        $cnt = $num_updates = $num_fails = $time = 0; 
     
    360415                    // Remove old intermediate thumbnails if any. 
    361416                    if ( $old_value && ! empty( $old_value[0]['sizes'] ) && is_array( $old_value[0]['sizes'] ) ) { 
    362                         if ( null === $upload_dir ) { 
    363                             $upload_dir = wp_get_upload_dir(); 
    364                             $basedir = $upload_dir['basedir']; 
    365                         } 
    366417                        $dirname = dirname( $file ) . '/'; 
    367418                        foreach ( $old_value[0]['sizes'] as $sizeinfo ) { 
    368                             $intermediate_file = $dirname . $sizeinfo['file']; 
    369                             @ unlink( path_join( $basedir, $intermediate_file ) ); 
     419                            @ unlink( $dirname . $sizeinfo['file'] ); 
    370420                        } 
    371421                    } 
     
    412462     */ 
    413463    static function regen_pdf_previews() { 
    414         if ( ! current_user_can( self::$cap ) ) { 
    415             wp_die( __( 'Sorry, you are not allowed to access this page.', 'gs-only-pdf-preview' ) ); 
    416         } 
     464        if ( ! current_user_can( self::$cap ) ) { // Double-check cap. 
     465            wp_die( __( 'Sorry, you are not allowed to access this page.', 'gs-only-pdf-preview' ), '', array( 'response' => 403 ) ); 
     466        } 
     467 
    417468        global $wpdb; 
    418469        $cnt = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_type = %s AND post_mime_type = %s", 'attachment', 'application/pdf' ) ); 
     
    468519                    ?> 
    469520                </p> 
    470                 <?php if ( defined( 'GOPP_PLUGIN_DEBUG' ) && GOPP_PLUGIN_DEBUG ) : ?> 
     521                <?php if ( ( defined( 'GOPP_PLUGIN_DEBUG' ) && GOPP_PLUGIN_DEBUG ) || ! self::check_have_gs() ) : ?> 
    471522                    <?php require_once dirname( __FILE__ ) . '/includes/debug-gopp-image-editor-gs.php'; ?> 
    472523                    <?php DEBUG_GOPP_Image_Editor_GS::dump(); ?> 
     
    501552                    'is_upload' => $is_upload, 
    502553                    'is_post' => $is_post, 
     554                    'current_user_can_cap' => current_user_can( self::$cap ), 
    503555                ), 
    504556            ); 
     
    537589 
    538590    /** 
    539      * Called on 'bulk_actions-upload' filter. 
     591     * Called on 'bulk_actions-upload' filter for users with cap. 
    540592     * Adds "Regenerate PDF Previews" to the bulk action dropdown in the list mode of the Media Library. 
    541593     */ 
    542594    static function bulk_actions_upload( $actions ) { 
    543         if ( current_user_can( self::$cap ) ) { 
     595        if ( self::check_have_gs() ) { 
    544596            $actions['gopp_regen_pdf_previews'] = __( 'Regenerate PDF Previews', 'gs-only-pdf-preview' ); 
    545597        } 
     
    548600 
    549601    /** 
    550      * Called on 'handle_bulk_actions-upload' filter. 
     602     * Called on 'handle_bulk_actions-upload' filter for users with cap. 
    551603     * Does the work of the "Regenerate PDF Previews" bulk action. 
    552604     */ 
    553605    static function handle_bulk_actions_upload( $location, $doaction, $post_ids ) { 
    554606 
    555         if ( 'gopp_regen_pdf_previews' === $doaction && current_user_can( self::$cap ) ) { 
     607        if ( 'gopp_regen_pdf_previews' === $doaction && current_user_can( self::$cap ) ) { // Double-check cap. 
    556608            // Note nonce has already been checked in "wp-admin/upload.php". 
    557609            // But $post_ids hasn't (and triggers a PHP Warning if nothing selected in "wp-admin/upload.php:168" as of WP 4.7.2). 
     
    566618 
    567619    /** 
    568      * Called on 'removable_query_args' filter. 
     620     * Called on 'removable_query_args' filter for users with cap. 
    569621     * Signals that our query arg should be removed from the URL. 
    570622     */ 
     
    575627 
    576628    /** 
    577      * Called on 'current_screen' action. 
     629     * Called on 'current_screen' action for users with cap. 
    578630     * Removes our query arg from the URL. 
    579631     */ 
     
    585637 
    586638    /** 
    587      * Called on 'media_row_actions' filter. 
     639     * Called on 'media_row_actions' filter for users with cap. 
    588640     * Adds the "Regenerate Preview" link to PDF rows in the list mode of the Media Library. 
    589641     */ 
    590642    static function media_row_actions( $actions, $post, $detached ) { 
    591         if ( 'application/pdf' === $post->post_mime_type && current_user_can( self::$cap ) ) { 
    592             self::load_gopp_image_editor_gs(); 
    593             if ( GOPP_Image_Editor_GS::test( array( 'path' => get_attached_file( $post->ID ) ) ) ) { 
    594                 $actions['gopp_regen_pdf_preview'] = sprintf( 
    595                     '<a href="#the-list" onclick="return gopp_plugin.media_row_action( event, %d, %s );" class="hide-if-no-js aria-button-if-js" aria-label="%s">%s</a>' . self::spinner( -3 ), 
    596                     $post->ID, 
    597                     esc_attr( json_encode( wp_create_nonce( 'gopp_media_row_action_' . $post->ID ) ) ), 
    598                     /* translators: %s: attachment title */ 
    599                     esc_attr( sprintf( __( 'Regenerate the PDF preview for &#8220;%s&#8221;', 'gs-only-pdf-preview' ), _draft_or_post_title() ) ), 
    600                     esc_attr( __( 'Regenerate&nbsp;Preview', 'gs-only-pdf-preview' ) ) 
    601                 ); 
    602             } 
     643        if ( 'application/pdf' === $post->post_mime_type && self::check_have_gs( get_attached_file( $post->ID ) ) ) { 
     644            $actions['gopp_regen_pdf_preview'] = sprintf( 
     645                '<a href="#the-list" onclick="return gopp_plugin.media_row_action( event, %d, %s );" class="hide-if-no-js aria-button-if-js" aria-label="%s">%s</a>' . self::spinner( -3 ), 
     646                $post->ID, 
     647                esc_attr( json_encode( wp_create_nonce( 'gopp_media_row_action_' . $post->ID ) ) ), 
     648                /* translators: %s: attachment title */ 
     649                esc_attr( sprintf( __( 'Regenerate the PDF preview for &#8220;%s&#8221;', 'gs-only-pdf-preview' ), _draft_or_post_title() ) ), 
     650                esc_attr( __( 'Regenerate&nbsp;Preview', 'gs-only-pdf-preview' ) ) 
     651            ); 
    603652        } 
    604653        return $actions; 
     
    612661        $ret = array( 'msg' => '', 'error' => false, 'img' => '' ); 
    613662 
    614         if ( ! current_user_can( self::$cap ) ) { 
     663        if ( ! current_user_can( self::$cap ) ) { // Double-check cap. 
    615664            $ret['error'] = __( 'Sorry, you are not allowed to access this page.', 'gs-only-pdf-preview' ); 
    616665        } else { 
     
    653702        $ret = array( 'msg' => '' ); 
    654703 
    655         if ( current_user_can( self::$cap ) ) { 
     704        if ( current_user_can( self::$cap ) ) { // Double-check cap. 
    656705            $cnt = isset( $_REQUEST['cnt'] ) && is_string( $_REQUEST['cnt'] ) ? intval( $_REQUEST['cnt'] ) : 0; 
    657706 
     
    676725    /** 
    677726     * Called on 'media_send_to_editor' filter. 
     727     * Patch to allow PDF thumbnail insertion (see #39618). 
    678728     */ 
    679729    static function media_send_to_editor( $html, $id, $attachment ) { 
     
    687737            $align = isset( $attachment['align'] ) ? $attachment['align'] : 'none'; 
    688738            $size = $attachment['image-size']; 
    689             $alt = isset( $attachment['image_alt'] ) ? $attachment['image_alt'] : ''; 
     739            // Not sure what sets 'image_alt' - may be legacy stuff. 
     740            $alt = isset( $attachment['image_alt'] ) ? $attachment['image_alt'] : ( isset( $attachment['alt'] ) ? $attachment['alt'] : '' ); 
    690741 
    691742            // No whitespace-only captions. 
  • gs-only-pdf-preview/trunk/includes/class-gopp-image-editor-gs.php

    r1594582 r1638565  
    7878     */ 
    7979    public static function test( $args = array() ) { 
     80        // Ensure given 'mime_type' arg, as if not _wp_image_editor_choose() won't call supports_mime_type() subsequently 
     81        // and will return this as a supporting implementation, which is probably not what callers expect. 
     82        if ( ! isset( $args['mime_type'] ) ) { 
     83            return false; 
     84        } 
     85 
    8086        // Check that exec() is (probably) available and we're not in safe_mode. 
    8187        if ( ! function_exists( 'exec' ) || ini_get( 'safe_mode' ) ) { 
     
    128134     */ 
    129135    public function load() { 
    130         $result = self::gs_valid( $this->file ); 
    131         if ( true !== $result ) { 
     136        if ( true !== ( $result = self::gs_valid( $this->file ) ) ) { 
    132137            return new WP_Error( 'invalid_image', $result, $this->file ); 
    133138        } 
     
    137142 
    138143        // Allow chance for gopp_editor_set_resolution filter to fire by calling set_resolution() with null arg (mimicking set_quality() behavior). 
    139         $this->set_resolution(); 
     144        if ( is_wp_error( $result = $this->set_resolution() ) ) { 
     145            return $result; 
     146        } 
    140147 
    141148        // Similarly for page to render. 
    142         $this->set_page(); 
     149        if ( is_wp_error( $result = $this->set_page() ) ) { 
     150            return $result; 
     151        } 
    143152 
    144153        return $this->set_quality(); 
     
    166175        } 
    167176 
    168         // Make sure not to overwrite existing JPEG with same name. 
     177        // Make sure not to overwrite existing JPEG with same name. Redundant now for WP 4.7.3+ after #39875, but keep for BC. 
    169178        $filename = $dirname . '/' . wp_unique_filename( $dirname, wp_basename( $filename ) ); 
    170179 
     
    179188        } 
    180189 
    181         // As this editor is immediately thrown away just do dummy size. Saves some cycles. 
    182         $size = array( 1088, 1408 ); // US Letter size at 128 DPI. Makes it pass the unit test Tests_Image_Functions::test_wp_generate_attachment_metadata_pdf(). 
    183         //$size = @ getimagesize( $filename ); 
     190        $size = @ getimagesize( $filename ); 
    184191        if ( ! $size ) { 
    185             return new WP_Error( 'image_save_error', __( 'Could not read image size.', 'gs-only-pdf-preview' ) ); // @codeCoverageIgnore 
     192            return new WP_Error( 'image_save_error', __( 'Could not read image size.', 'gs-only-pdf-preview' ) ); 
    186193        } 
    187194 
     
    382389                                if ( self::test_gs_cmd( $possible_path ) ) { 
    383390                                    $best_match = $possible_path; 
     391                                    $highest_ver = $ver; 
    384392                                } 
    385393                            } 
     
    396404        if ( ! $win_path ) { 
    397405            // Try GSC environment variable. TODO: Is this still used? 
    398             $gsc = getenv( 'GSC' ); 
    399             if ( $gsc && is_string( $gsc ) && self::test_gs_cmd( $gsc ) ) { 
    400                 $win_path = $gsc; 
     406            if ( ! empty( $_SERVER['GSC'] ) && is_string( $_SERVER['GSC'] ) && self::test_gs_cmd( $_SERVER['GSC'] ) ) { 
     407                $win_path = $_SERVER['GSC']; 
    401408            } 
    402409        } 
     
    431438                                if ( @ is_executable( $gs_entry . '\\bin\\gswin64c.exe' ) && self::test_gs_cmd( $gs_entry . '\\bin\\gswin64c.exe' ) ) { 
    432439                                    $best_match = $gs_entry . '\\bin\\gswin64c.exe'; 
     440                                    $highest_ver = $ver; 
    433441                                } elseif ( @ is_executable( $gs_entry . '\\bin\\gswin32c.exe' ) && self::test_gs_cmd( $gs_entry . '\\bin\\gswin32c.exe' ) ) { 
    434442                                    $best_match = $gs_entry . '\\bin\\gswin32c.exe'; 
     443                                    $highest_ver = $ver; 
    435444                                } 
    436445                            } 
     
    787796        return new WP_Error( 'image_stream_error', __( 'Unsupported operation.', 'gs-only-pdf-preview' ) ); 
    788797    } 
     798 
     799    /** 
     800     * Gets dimensions of image. 
     801     * 
     802     * @since 3.5.0 
     803     * @access public 
     804     * 
     805     * @return array {'width'=>int, 'height'=>int} 
     806     */ 
     807    public function get_size() { 
     808        // If size hasn't been set yet and have loaded. 
     809        if ( null === $this->size && $this->mime_type ) { 
     810            $this->update_size( 0, 0 ); 
     811            // Do a temporary full preview to get size of image. 
     812            $dirname = untrailingslashit( get_temp_dir() ); 
     813            $filename = $dirname . '/' . wp_unique_filename( $dirname, 'gopp_size.jpg' ); 
     814            if ( $cmd = self::gs_cmd( $this->get_gs_args( $filename ) ) ) { 
     815                exec( $cmd, $output, $return_var ); 
     816                if ( 0 === $return_var && ( $size = @ getimagesize( $filename ) ) ) { 
     817                    $this->update_size( $size[0], $size[1] ); 
     818                } 
     819                @ unlink( $filename ); 
     820            } 
     821        } 
     822        return $this->size; 
     823    } 
    789824} 
  • gs-only-pdf-preview/trunk/includes/debug-gopp-image-editor-gs.php

    r1578349 r1638565  
    99class DEBUG_GOPP_Image_Editor_GS extends GOPP_Image_Editor_GS { 
    1010    static function get_test_output() { 
    11         $cmd = self::gs_cmd( '-dBATCH -dNOPAUSE -dNOPROMPT -dSAFER -v' ); 
    12         exec( $cmd, $output, $return_var ); 
    13         return array( $return_var, $output ); 
     11        if ( $cmd = self::gs_cmd( '-dBATCH -dNOPAUSE -dNOPROMPT -dSAFER -v' ) ) { 
     12            exec( $cmd, $output, $return_var ); 
     13            return array( $return_var, $output ); 
     14        } 
     15        return array( -1, array( __( 'Ghostscript command not found!', 'gs-only-pdf-preview' ) ) ); 
    1416    } 
    1517 
     
    2325 
    2426    static function dump() { 
     27        $args = array( 'mime_type' => 'application/pdf' ); 
    2528        list( $return_var, $output ) = self::get_test_output(); 
    2629        ?> 
     
    3134                <tr><td valign="top">Output</td><td><strong><?php echo implode( '<br />', $output ); ?></strong></td></tr> 
    3235                <tr><td>gs_cmd_path</td><td><strong><?php echo self::gs_cmd_path(); ?></strong> </td></tr> 
    33                 <tr><td>test</td><td><strong><?php echo self::test() ? 'true' : 'false'; ?></strong> </td></tr> 
     36                <tr><td>test</td><td><strong><?php echo self::test( $args ) ? 'true' : 'false'; ?></strong> </td></tr> 
    3437                <tr><td>is_win</td><td><strong><?php echo self::is_win() ? 'true' : 'false'; ?></strong> </td></tr> 
    3538                <tr><td>Transient <em>gopp_image_gs_cmd_path</em></td><td><strong><?php echo self::transient_gopp_image_gs_cmd_path(); ?></strong> </td></tr> 
  • gs-only-pdf-preview/trunk/js/gs-only-pdf-preview.js

    r1594582 r1638565  
    5858     * Regenerate Preview row action. 
    5959     */ 
    60     gopp_plugin.media_row_action = function ( e, id, nonce ) { 
    61         var $target = $( e.target ), $row_action_div = $target.parents( '.row-actions' ).first(), $spinner = $target.next(); 
    62         $( '.gopp_response', $row_action_div.parent() ).remove(); 
     60    gopp_plugin.media_row_action = function ( e, id, nonce, test ) { 
     61        var $target = $( e.target ), $row_action_div = $target.parents( '.row-actions' ).first(), $row_action_parent = $row_action_div.parent(), $spinner = $target.next(), post_ret; 
     62        $( '.gopp_response', $row_action_parent ).remove(); 
    6363        $spinner.addClass( 'is-active' ); 
    64         $.post( { 
     64        post_ret = $.post( { 
    6565            url: ajaxurl, 
    6666            data: { 
     
    7878            success: function( data ) { 
    7979                $spinner.removeClass( 'is-active' ); 
    80                 $( '.gopp_response', $row_action_div.parent() ).remove(); 
     80                $( '.gopp_response', $row_action_parent ).remove(); 
    8181                if ( data ) { 
    8282                    if ( data.error ) { 
     
    8686                    } 
    8787                    if ( data.img ) { 
    88                         $( '.has-media-icon .media-icon', $row_action_div.parent() ).html( data.img ); 
     88                        $( '.has-media-icon .media-icon', $row_action_parent ).html( data.img ); 
    8989                    } 
    9090                } else { 
     
    9595        } ); 
    9696 
     97        post_ret.fail( function () { 
     98            $spinner.removeClass( 'is-active' ); 
     99        } ); 
     100 
     101        if ( test ) { 
     102            test.post_ret = post_ret; 
     103        } 
    97104        return false; 
    98105    }; 
     
    104111        $( '#doaction, #doaction2' ).click( function ( e ) { 
    105112            $( 'select[name^="action"]' ).each( function () { 
    106                 var $target, checkeds; 
     113                var $target, $parent, checkeds; 
    107114                if ( 'gopp_regen_pdf_previews' === $( this ).val() ) { 
    108115                    $target = $( e.target ); 
     116                    $parent = $target.parent(); 
     117                    $( '.gopp_none', $parent ).remove(); 
     118                    $( '.spinner', $parent ).remove(); 
    109119                    // See if anything selected. 
    110120                    checkeds = $.makeArray( $( '#the-list input[name="media[]"]:checked' ).map( function () { 
     
    113123                    if ( ! checkeds.length ) { 
    114124                        e.preventDefault(); 
    115                         $( '.gopp_none', $target.parent() ).remove(); 
    116125                        $( gopp_plugin_params.no_items_selected_msg ).insertAfter( $target ).fadeOut( 1000, function() { $( this ).remove(); } ); 
    117126                    } else { 
    118                         $( '.spinner', $target.parent() ).remove(); 
    119127                        $( gopp_plugin_params.spinner ).insertAfter( $target ); // Like above, as in submit, doesn't work for Safari. 
    120128                    } 
     
    125133 
    126134    /** 
     135     * Patches Attachment Details template. 
     136     */ 
     137    gopp_plugin.upload_patch = function () { 
     138        var $tmpl_attachment_details_two_column, html_before, 
     139            html_attachment_details_two_column, 
     140            attachment_details_two_column_re = /(<# if \( 'image' === data.type)( \) { #>\s+<label class="setting" data-setting="alt">)/, 
     141            attachment_details_two_column_with = '$1 || data.sizes$2'; 
     142 
     143        $tmpl_attachment_details_two_column = $( '#tmpl-attachment-details-two-column' ); 
     144        if ( $tmpl_attachment_details_two_column.length ) { 
     145 
     146            // Enable "Alt Text" in Attachment Details Two Column. 
     147            html_before = $tmpl_attachment_details_two_column.html(); 
     148            html_attachment_details_two_column = html_before.replace( attachment_details_two_column_re, attachment_details_two_column_with ); 
     149            if ( html_before === html_attachment_details_two_column ) { 
     150                return false; 
     151            } 
     152 
     153            $tmpl_attachment_details_two_column.html( html_attachment_details_two_column ); 
     154 
     155            return true; 
     156        } 
     157        return false; 
     158    }; 
     159 
     160    /** 
    127161     * Patches templates and wp.media.editor.send.attachment to allow PDF thumbnail insertion (see #39618). 
    128      * Also addresses #39630 by using either thumbnail or medium sized thumbnails in Media Library, favouring thumbnail size. 
    129      */ 
    130     gopp_plugin.post = function () { 
     162     */ 
     163    gopp_plugin.post_patch = function () { 
    131164        var $tmpl_attachment_details, $tmpl_attachment_display_settings, $tmpl_image_details, html_before, 
    132165            html_attachment_details, 
    133166            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', 
     167            attachment_details_with = '$1\n<# } else if ( data.sizes && ( data.sizes.thumbnail || data.sizes.full ) ) { #>\n<img src="{{ ( data.sizes.thumbnail || data.sizes.full ).url }}" draggable="false" alt="" />\n$2', 
     168            attachment_details2_re = /(<# if \( 'image' === data.type)( \) { #>\s+<label class="setting" data-setting="alt")/, 
     169            attachment_details2_with = '$1 || ( \'application\' === data.type && data.sizes )$2', 
    135170            html_attachment_display_settings, 
    136171            attachment_display_settings_re = /(<# if \( 'image' === data.type)( \) { #>\s+<label class="setting">)/, 
     
    157192                } 
    158193 
     194                // Enables "Alt Text" input in Attachment Details. 
     195                html_before = html_attachment_details; 
     196                html_attachment_details = html_before.replace( attachment_details2_re, attachment_details2_with ); 
     197                if ( html_before === html_attachment_details ) { 
     198                    return false; 
     199                } 
     200 
    159201                // #39618 Enables "Align" select of Attachment Display Settings. 
    160202                html_before = $tmpl_attachment_display_settings.html(); 
     
    174216                html_image_details = html_before.replace( image_details_re, image_details_with ); 
    175217                if ( html_before === html_image_details ) { 
    176                     return false; 
    177                 } 
    178  
    179                 // #39630 Use either thumbnail or medium sized thumbnails in Media Library. 
    180                 if ( false === gopp_plugin.patch_39630() ) { 
    181218                    return false; 
    182219                } 
     
    244281            options.post_title = props.title; 
    245282            // gitlost begin. 
    246             if ( 'application' === attachment.type && 'pdf' === attachment.subtype ) { 
     283            if ( attachment.sizes ) { 
     284                // Not picked into props for non-images in wp.media.string.props(). 
     285                if ( attachment.alt ) { 
     286                    options.alt = attachment.alt; 
     287                } 
    247288                _.each({ 
    248289                    align: 'align', 
    249                     size:  'image-size' 
     290                    size:  'image-size', 
     291                    alt:   'image_alt' 
    250292                }, function( option, prop ) { 
    251293                    if ( props[ prop ] ) 
     
    265307 
    266308    /** 
    267      * Patches 'tmpl-attachment in "wp-includes/media-templates.php" to use either thumbnail or medium sized thumbnails in Media Library, favouring thumbnail size. 
     309     * Addresses #39630 by patching 'tmpl-attachment' in "wp-includes/media-templates.php" to use either thumbnail or medium sized thumbnails in Media Library, favouring thumbnail size. 
    268310     */ 
    269311    gopp_plugin.patch_39630 = function () { 
    270312        var $tmpl_attachment = $( '#tmpl-attachment' ), html_before, html_attachment, 
    271313            attachment_re = /(<# } else if \( data\.sizes && )data\.sizes\.medium( \) { #>\s+<img src="{{ )data\.sizes\.medium(\.url }}" class="thumbnail" draggable="false" alt="" \/>\s+<# } else { #>)/, 
    272             attachment_with = '$1( data.sizes.thumbnail || data.sizes.medium )$2( data.sizes.thumbnail || data.sizes.medium )$3'; 
     314            attachment_with = '$1( data.sizes.thumbnail || data.sizes.medium || data.sizes.full )$2( data.sizes.thumbnail || data.sizes.medium || data.sizes.full )$3'; 
    273315 
    274316        if ( $tmpl_attachment.length ) { 
     
    290332        if ( gopp_plugin_params && gopp_plugin_params.val ) { 
    291333            if ( gopp_plugin_params.val.is_regen_pdf_preview ) { 
    292                 gopp_plugin.regen_pdf_preview(); 
     334                if ( gopp_plugin_params.val.current_user_can_cap ) { 
     335                    gopp_plugin.regen_pdf_preview(); 
     336                } 
    293337            } else if ( gopp_plugin_params.val.is_upload ) { 
    294                 gopp_plugin.upload(); 
     338                if ( gopp_plugin_params.val.current_user_can_cap ) { 
     339                    gopp_plugin.upload(); 
     340                } 
     341                // Always try the patches. 
     342                gopp_plugin.upload_patch(); 
    295343                gopp_plugin.patch_39630(); 
    296344            } else if ( gopp_plugin_params.val.is_post ) { 
    297                 gopp_plugin.post(); 
     345                // Always try the patches. 
     346                gopp_plugin.post_patch(); 
     347                gopp_plugin.patch_39630(); 
    298348            } 
    299349        } 
  • gs-only-pdf-preview/trunk/js/gs-only-pdf-preview.min.js

    r1594582 r1638565  
    1 /*! gs-only-pdf-preview 1.0.4 2017-02-13 */ 
    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="" />\n$2',k=/(<# if \( 'image' === data.type)( \) { #>\s+<label class="setting">)/,l="$1 || ( 'application' === data.type && data.sizes )$2",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),a.link&&(c.link_to=a.link),"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.5 2017-04-16 */ 
     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,e){var f,g=a(b.target),h=g.parents(".row-actions").first(),i=h.parent(),j=g.next();return a(".gopp_response",i).remove(),j.addClass("is-active"),f=a.post({url:ajaxurl,data:{action:"gopp_media_row_action",id:c,nonce:d},dataType:"json",error:function(b,c,d){var e;j.removeClass("is-active"),e='<div class="notice error gopp_response"><p>'+gopp_plugin_params.action_not_available+" ("+d+")</p></div>",h.after(a(e))},success:function(b){j.removeClass("is-active"),a(".gopp_response",i).remove(),b?(b.error?h.after(a('<div class="notice error gopp_response"><p>'+b.error+"</p></div>")):b.msg&&h.after(a('<div class="notice updated gopp_response"><p>'+b.msg+"</p></div>")),b.img&&a(".has-media-icon .media-icon",i).html(b.img)):h.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}),f.fail(function(){j.removeClass("is-active")}),e&&(e.post_ret=f),!1},gopp_plugin.upload=function(){a("#doaction, #doaction2").click(function(b){a('select[name^="action"]').each(function(){var c,d,e;"gopp_regen_pdf_previews"===a(this).val()&&(c=a(b.target),d=c.parent(),a(".gopp_none",d).remove(),a(".spinner",d).remove(),e=a.makeArray(a('#the-list input[name="media[]"]:checked').map(function(){return this.value})),e.length?a(gopp_plugin_params.spinner).insertAfter(c):(b.preventDefault(),a(gopp_plugin_params.no_items_selected_msg).insertAfter(c).fadeOut(1e3,function(){a(this).remove()})))})})},gopp_plugin.upload_patch=function(){var b,c,d;return b=a("#tmpl-attachment-details-two-column"),!!b.length&&(c=b.html(),d=c.replace(/(<# if \( 'image' === data.type)( \) { #>\s+<label class="setting" data-setting="alt">)/,"$1 || data.sizes$2"),c!==d&&(b.html(d),!0))},gopp_plugin.post_patch=function(){var b,c,d,e,f,g,h,i="$1\n<# if ( 'application' === data.type ) { #>\n<option value=\"\">\n"+gopp_plugin_params.document_link_only+"\n</option>\n<# } #>\n$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(/(<# } else if \( 'image' === data\.type && data\.sizes \) { #>\s+<img src="{{ data\.size\.url }}" draggable="false" alt="" \/>)(\s+<# } else { #>)/,'$1\n<# } else if ( data.sizes && ( data.sizes.thumbnail || data.sizes.full ) ) { #>\n<img src="{{ ( data.sizes.thumbnail || data.sizes.full ).url }}" draggable="false" alt="" />\n$2'),e!==f&&(e=f,f=e.replace(/(<# if \( 'image' === data.type)( \) { #>\s+<label class="setting" data-setting="alt")/,"$1 || ( 'application' === data.type && data.sizes )$2"),e!==f&&(e=c.html(),g=e.replace(/(<# if \( 'image' === data.type)( \) { #>\s+<label class="setting">)/,"$1 || ( 'application' === data.type && data.sizes )$2"),e!==g&&(e=g,g=e.replace(/(<# if \( data\.userSettings \) { #>\s+data-user-setting="imgsize"\s+<# } #>>)(\s+<#)/,i),e!==g&&(e=d.html(),h=e.replace(/(<# if \( data\.attachment && window\.imageEdit)( \) { #>)/,"$1 && 'image' === data.type $2"),e!==h&&(b.html(f),c.html(g),d.html(h),wp.media.editor.send.attachment=gopp_plugin.media_editor_send_attachment,!0))))))},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),a.link&&(c.link_to=a.link),"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,b.sizes&&(b.alt&&(c.alt=b.alt),_.each({align:"align",size:"image-size",alt:"image_alt"},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");return!!d.length&&(b=d.html(),c=b.replace(/(<# } else if \( data\.sizes && )data\.sizes\.medium( \) { #>\s+<img src="{{ )data\.sizes\.medium(\.url }}" class="thumbnail" draggable="false" alt="" \/>\s+<# } else { #>)/,"$1( data.sizes.thumbnail || data.sizes.medium || data.sizes.full )$2( data.sizes.thumbnail || data.sizes.medium || data.sizes.full )$3"),b!==c&&(d.html(c),!0))},a(function(){gopp_plugin_params&&gopp_plugin_params.val&&(gopp_plugin_params.val.is_regen_pdf_preview?gopp_plugin_params.val.current_user_can_cap&&gopp_plugin.regen_pdf_preview():gopp_plugin_params.val.is_upload?(gopp_plugin_params.val.current_user_can_cap&&gopp_plugin.upload(),gopp_plugin.upload_patch(),gopp_plugin.patch_39630()):gopp_plugin_params.val.is_post&&(gopp_plugin.post_patch(),gopp_plugin.patch_39630()))})}(jQuery); 
  • gs-only-pdf-preview/trunk/languages/gs-only-pdf-preview-fr_FR.po

    r1594582 r1638565  
    33msgid "" 
    44msgstr "" 
    5 "Project-Id-Version: GS Only PDF Preview 1.0.4\n" 
     5"Project-Id-Version: GS Only PDF Preview 1.0.5\n" 
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/gs-only-pdf-" 
    77"preview\n" 
    8 "POT-Creation-Date: 2017-02-13 03:13+0000\n" 
    9 "PO-Revision-Date: 2017-02-13 03:13+0000\n" 
     8"POT-Creation-Date: 2017-04-16 14:40+0100\n" 
     9"PO-Revision-Date: 2017-04-16 14:40+0100\n" 
    1010"Last-Translator: gitlost <gitlost@gitlostbonger.com>\n" 
    1111"Language-Team: \n" 
     
    2525 
    2626#. translators: %s: url to admin plugins page. 
    27 #: gs-only-pdf-preview.php:93 
     27#: gs-only-pdf-preview.php:98 
    2828msgid "" 
    2929"The plugin \"GS Only PDF Preview\" cannot be activated as it relies on the " 
     
    3939 
    4040#. translators: %s: url to admin plugins page. 
    41 #: gs-only-pdf-preview.php:99 
     41#: gs-only-pdf-preview.php:106 
    4242msgid "" 
    4343"The plugin \"GS Only PDF Preview\" cannot be activated as it relies on the " 
     
    5151 
    5252#. translators: %s: url to admin plugins page. 
    53 #: gs-only-pdf-preview.php:112 
    54 msgid "" 
    55 "The plugin \"GS Only PDF Preview\" cannot be activated as it relies on the " 
    56 "PHP function <code>exec</code>, which has been disabled on your system via " 
    57 "the suhosin extension directive <code>suhosin.executor.func.blacklist</" 
    58 "code>. <a href=\"%s\">Return to Plugins page.</a>" 
    59 msgstr "" 
    60 "L&rsquo;extension &laquo;&nbsp;GS Only PDF Preview&nbsp;&raquo; ne peut pas " 
    61 "être activée parce qu&rsquo;elle dépend de la fonction de PHP <code>exec</" 
    62 "code>, qui est désactivée sur votre système via la directive d&rsquo;" 
    63 "extension de suhosin <code>suhosin.executor.func.blacklist</code>. <a href=" 
    64 "\"%s\">Retournez sur la page des extensions.</a>" 
    65  
    66 #. translators: %s: url to admin plugins page. 
    67 #: gs-only-pdf-preview.php:124 
     53#: gs-only-pdf-preview.php:125 
    6854msgid "" 
    6955"The plugin \"GS Only PDF Preview\" cannot be activated as it is incompatible " 
     
    7864#. translators: %1$s: lowest compatible WordPress version; %2$s: user's current 
    7965#. WordPress version; %3$s: url to admin plugins page. 
    80 #: gs-only-pdf-preview.php:140 
     66#: gs-only-pdf-preview.php:141 
    8167msgid "" 
    8268"The plugin \"GS Only PDF Preview\" cannot be activated as it requires " 
     
    9076#. translators: %1$s: highest WordPress version tested; %2$s: user's current 
    9177#. WordPress version. 
    92 #: gs-only-pdf-preview.php:153 
     78#: gs-only-pdf-preview.php:154 
    9379msgid "" 
    9480"<strong>Warning: untested!</strong> The plugin \"GS Only PDF Preview\" has " 
     
    9985"versions de WordPress justqu&rsquo;à %1$s. Vous avez WordPress version %2$s." 
    10086 
    101 #: gs-only-pdf-preview.php:165 
     87#. translators: %1$s: name of suhosin extension directive; %2$s: url to admin 
     88#. plugins page. 
     89#: gs-only-pdf-preview.php:183 gs-only-pdf-preview.php:193 
     90msgid "" 
     91"The plugin \"GS Only PDF Preview\" cannot be activated as it relies on the " 
     92"PHP function <code>exec</code>, which has been disabled on your system via " 
     93"the suhosin extension directive <code>%1$s</code>. <a href=\"%2$s\">Return " 
     94"to Plugins page.</a>" 
     95msgstr "" 
     96"L&rsquo;extension &laquo;&nbsp;GS Only PDF Preview&nbsp;&raquo; ne peut pas " 
     97"être activée parce qu&rsquo;elle dépend de la fonction de PHP <code>exec</" 
     98"code>, qui est désactivée sur votre système via la directive d&rsquo;" 
     99"extension de suhosin <code>%1$s</code>. <a href=\"%2$s\">Retournez sur la " 
     100"page des extensions.</a>" 
     101 
     102#: gs-only-pdf-preview.php:231 
    102103msgid "" 
    103104"<strong>Warning: no Ghostscript!</strong> The plugin \"GS Only PDF Preview\" " 
     
    108109"déterminer l&rsquo;emplacement du serveur de votre exécutable Ghostscript." 
    109110 
    110 #: gs-only-pdf-preview.php:218 
     111#: gs-only-pdf-preview.php:271 
    111112msgid "Invalid arguments!" 
    112113msgstr "Paramètres invalides&nbsp;!" 
    113114 
    114 #: gs-only-pdf-preview.php:223 
     115#: gs-only-pdf-preview.php:276 
    115116msgid "No PDFs found!" 
    116117msgstr "Aucun fichier PDF trouvé&nbsp;!" 
     
    118119#. translators: %1$s: formatted number of PDF previews regenerated; %2$s: 
    119120#. formatted number of seconds to one decimal place it took. 
    120 #: gs-only-pdf-preview.php:229 
     121#: gs-only-pdf-preview.php:282 
    121122msgid "%1$s PDF preview regenerated in %2$s seconds." 
    122123msgid_plural "%1$s PDF previews regenerated in %2$s seconds." 
     
    125126 
    126127#. translators: %s: formatted number of non-PDFs ignored. 
    127 #: gs-only-pdf-preview.php:236 
     128#: gs-only-pdf-preview.php:289 
    128129msgid "%s non-PDF ignored." 
    129130msgid_plural "%s non-PDFs ignored." 
     
    131132msgstr[1] "%s non PDFs ignorés." 
    132133 
    133 #: gs-only-pdf-preview.php:241 
     134#: gs-only-pdf-preview.php:294 
    134135msgid "Nothing updated!" 
    135136msgstr "Rien mis à jour&nbsp;!" 
    136137 
    137138#. translators: %s: formatted number of non-PDFs ignored. 
    138 #: gs-only-pdf-preview.php:245 
     139#: gs-only-pdf-preview.php:298 
    139140msgid "Nothing updateable! %s non-PDF ignored." 
    140141msgid_plural "Nothing updateable! %s non-PDFs ignored." 
     
    143144 
    144145#. translators: %s: formatted number of PDF previews that failed to regenerate. 
    145 #: gs-only-pdf-preview.php:252 
     146#: gs-only-pdf-preview.php:305 
    146147msgid "%s PDF preview not regenerated." 
    147148msgid_plural "%s PDF previews not regenerated." 
     
    149150msgstr[1] "%s aperçus de miniature de PDF non régénérés." 
    150151 
    151 #: gs-only-pdf-preview.php:258 
     152#: gs-only-pdf-preview.php:311 
    152153msgid "You can go again below if you want." 
    153154msgstr "Vous pouvez aller de nouveau ci-dessous si vous voulez." 
    154155 
    155 #: gs-only-pdf-preview.php:296 gs-only-pdf-preview.php:450 
    156 #: gs-only-pdf-preview.php:544 
     156#: gs-only-pdf-preview.php:349 gs-only-pdf-preview.php:501 
     157#: gs-only-pdf-preview.php:596 
    157158msgid "Regenerate PDF Previews" 
    158159msgstr "Régénérer les aperçus de miniature de PDF" 
    159160 
    160 #: gs-only-pdf-preview.php:296 
     161#: gs-only-pdf-preview.php:349 
    161162msgid "Regen. PDF Previews" 
    162163msgstr "Régén. aperçus PDF" 
    163164 
    164 #: gs-only-pdf-preview.php:310 gs-only-pdf-preview.php:415 
    165 #: gs-only-pdf-preview.php:615 
     165#: gs-only-pdf-preview.php:363 gs-only-pdf-preview.php:465 
     166#: gs-only-pdf-preview.php:664 
    166167msgid "Sorry, you are not allowed to access this page." 
    167168msgstr "" 
     
    169170"page. " 
    170171 
    171 #: gs-only-pdf-preview.php:421 
     172#: gs-only-pdf-preview.php:472 
    172173msgid "GS Only PDF Preview - Regenerate PDF Previews" 
    173174msgstr "GS Only PDF Preview -  Régénérer les aperçus de miniature de PDF." 
    174175 
    175 #: gs-only-pdf-preview.php:426 
     176#: gs-only-pdf-preview.php:477 
    176177msgid "" 
    177178"This tool is for regenerating the thumbnail previews of PDFs, but no PDFs " 
     
    181182"fichier PDF n&rsquo;a été téléchargé, donc il n&rsquo;a rien à faire." 
    182183 
    183 #: gs-only-pdf-preview.php:433 
     184#: gs-only-pdf-preview.php:484 
    184185msgid "" 
    185186"<strong>Warning: cannot set max execution time!</strong> The maximum time " 
     
    192193"donc éprouver l&rsquo;écran blanc de mort (WSOD) en essayant ceci." 
    193194 
    194 #: gs-only-pdf-preview.php:442 
     195#: gs-only-pdf-preview.php:493 
    195196msgid "Regenerate the thumbnail previews of PDFs uploaded to your system." 
    196197msgstr "" 
     
    199200 
    200201#. translators: %s: formatted number of PDFs found. 
    201 #: gs-only-pdf-preview.php:447 
     202#: gs-only-pdf-preview.php:498 
    202203msgid "<strong>%s</strong> PDF has been found." 
    203204msgid_plural "<strong>%s</strong> PDFs have been found." 
     
    206207 
    207208#. translators: %s: formatted number (greater than 10) of PDFs found. 
    208 #: gs-only-pdf-preview.php:455 
     209#: gs-only-pdf-preview.php:506 
    209210msgid "Regenerating %s PDF previews can take a long time." 
    210211msgstr "" 
     
    212213 
    213214#. translators: %s: url to the Media Library page in list mode. 
    214 #: gs-only-pdf-preview.php:467 
     215#: gs-only-pdf-preview.php:518 
    215216msgid "" 
    216217"Note that you can also regenerate PDF previews in batches or individually " 
     
    225226"<a href=\"%s\">mode de liste de la bibliothèque des médias</a>." 
    226227 
    227 #: gs-only-pdf-preview.php:506 
     228#: gs-only-pdf-preview.php:558 
    228229msgid "Please wait..." 
    229230msgstr "S&rsquo;il vous plaît attendre..." 
    230231 
    231 #: gs-only-pdf-preview.php:510 
     232#: gs-only-pdf-preview.php:562 
    232233msgid "No items selected!" 
    233234msgstr "Aucun élément sélectionné&nbsp;!" 
    234235 
    235 #: gs-only-pdf-preview.php:511 
     236#: gs-only-pdf-preview.php:563 
    236237msgid "Regenerate Preview ajax action not available!" 
    237238msgstr "" 
    238239"L&rsquo;action de régénérer l&rsquo;aperçu n&rsquo;est pas disponible&nbsp;!" 
    239240 
    240 #: gs-only-pdf-preview.php:515 
     241#: gs-only-pdf-preview.php:567 
    241242msgid "Document Link Only" 
    242243msgstr "Lien de document seulement" 
    243244 
    244245#. translators: %s: attachment title 
    245 #: gs-only-pdf-preview.php:599 
     246#: gs-only-pdf-preview.php:649 
    246247msgid "Regenerate the PDF preview for &#8220;%s&#8221;" 
    247248msgstr "Régénérer l&rsquo;aperçu de miniature de PDF pour &#8220;%s&#8221;" 
    248249 
    249 #: gs-only-pdf-preview.php:600 
     250#: gs-only-pdf-preview.php:650 
    250251msgid "Regenerate&nbsp;Preview" 
    251252msgstr "Régénérer&nbsp;l&rsquo;aperçu" 
    252253 
    253 #: gs-only-pdf-preview.php:620 
     254#: gs-only-pdf-preview.php:669 
    254255msgid "Invalid nonce." 
    255256msgstr "Nonce invalide." 
    256257 
    257 #: gs-only-pdf-preview.php:623 
     258#: gs-only-pdf-preview.php:672 
    258259msgid "Invalid ID." 
    259260msgstr "Identifiant invalide." 
    260261 
    261 #: gs-only-pdf-preview.php:629 
     262#: gs-only-pdf-preview.php:678 
    262263msgid "Failed to generate the PDF preview." 
    263264msgstr "Échec de générer l&rsquo;aperçu de miniature de PDF." 
    264265 
    265 #: gs-only-pdf-preview.php:634 
     266#: gs-only-pdf-preview.php:683 
    266267msgid "" 
    267268"Successfully regenerated the PDF preview. It's best to refresh your browser " 
     
    272273"jour correctement." 
    273274 
    274 #: gs-only-pdf-preview.php:636 
     275#: gs-only-pdf-preview.php:685 
    275276msgid "" 
    276277"Successfully regenerated the PDF preview. You will need to refresh your " 
     
    282283#. translators: %1$d: percentage of PDF previews completed; %2$d: completed 
    283284#. count. 
    284 #: gs-only-pdf-preview.php:665 
     285#: gs-only-pdf-preview.php:714 
    285286msgid "%d%% (%d)" 
    286287msgstr "%d%% (%d)" 
    287288 
    288 #: includes/class-gopp-image-editor-gs.php:161 
     289#: includes/class-gopp-image-editor-gs.php:170 
    289290msgid "Unsupported MIME type." 
    290291msgstr "Type MIME non supporté." 
    291292 
    292 #: includes/class-gopp-image-editor-gs.php:165 
     293#: includes/class-gopp-image-editor-gs.php:174 
    293294msgid "Unsupported destination." 
    294295msgstr "Destination non supportée." 
    295296 
    296 #: includes/class-gopp-image-editor-gs.php:172 
     297#: includes/class-gopp-image-editor-gs.php:181 
    297298msgid "No Ghostscript." 
    298299msgstr "Pas de Ghostscript." 
    299300 
    300 #: includes/class-gopp-image-editor-gs.php:178 
     301#: includes/class-gopp-image-editor-gs.php:187 
    301302msgid "Image Editor Save Failed" 
    302303msgstr "L&rsquo;enregistrement de l&rsquo;éditeur d&rsquo;images a échoué." 
    303304 
    304 #: includes/class-gopp-image-editor-gs.php:185 
     305#: includes/class-gopp-image-editor-gs.php:192 
    305306msgid "Could not read image size." 
    306307msgstr "Impossible de lire la taille de l&rsquo;image." 
    307308 
    308 #: includes/class-gopp-image-editor-gs.php:223 
     309#: includes/class-gopp-image-editor-gs.php:230 
    309310msgid "Loading from URL not supported." 
    310311msgstr "Chargement à partir de l&rsquo;URL non pris en charge." 
    311312 
    312 #: includes/class-gopp-image-editor-gs.php:228 
    313 #: includes/class-gopp-image-editor-gs.php:234 
     313#: includes/class-gopp-image-editor-gs.php:235 
     314#: includes/class-gopp-image-editor-gs.php:241 
    314315msgid "Unsupported file name." 
    315316msgstr "Nom du fichier non supporté." 
    316317 
    317 #: includes/class-gopp-image-editor-gs.php:244 
     318#: includes/class-gopp-image-editor-gs.php:251 
    318319msgid "File doesn&#8217;t exist?" 
    319320msgstr "Le fichier n&rsquo;existe pas&nbsp;?" 
    320321 
    321 #: includes/class-gopp-image-editor-gs.php:251 
     322#: includes/class-gopp-image-editor-gs.php:258 
    322323msgid "File is not a PDF." 
    323324msgstr "Le fichier n&rsquo;est pas un PDF ." 
    324325 
    325 #: includes/class-gopp-image-editor-gs.php:633 
     326#: includes/class-gopp-image-editor-gs.php:642 
    326327msgid "Attempted to set PDF preview resolution to an invalid value." 
    327328msgstr "" 
     
    329330"valeur non valide." 
    330331 
    331 #: includes/class-gopp-image-editor-gs.php:688 
     332#: includes/class-gopp-image-editor-gs.php:697 
    332333msgid "Attempted to set PDF preview page to an invalid value." 
    333334msgstr "" 
     
    335336"non valide." 
    336337 
    337 #: includes/class-gopp-image-editor-gs.php:707 
    338 #: includes/class-gopp-image-editor-gs.php:728 
    339 #: includes/class-gopp-image-editor-gs.php:747 
    340 #: includes/class-gopp-image-editor-gs.php:760 
    341 #: includes/class-gopp-image-editor-gs.php:774 
    342 #: includes/class-gopp-image-editor-gs.php:787 
     338#: includes/class-gopp-image-editor-gs.php:716 
     339#: includes/class-gopp-image-editor-gs.php:737 
     340#: includes/class-gopp-image-editor-gs.php:756 
     341#: includes/class-gopp-image-editor-gs.php:769 
     342#: includes/class-gopp-image-editor-gs.php:783 
     343#: includes/class-gopp-image-editor-gs.php:796 
    343344msgid "Unsupported operation." 
    344345msgstr "Opération non supportée." 
     346 
     347#: includes/debug-gopp-image-editor-gs.php:15 
     348msgid "Ghostscript command not found!" 
     349msgstr "Commande Ghostscript introuvable&nbsp;!" 
    345350 
    346351#. Plugin Name of the plugin/theme 
  • gs-only-pdf-preview/trunk/languages/gs-only-pdf-preview.pot

    r1594582 r1638565  
    33msgid "" 
    44msgstr "" 
    5 "Project-Id-Version: GS Only PDF Preview 1.0.4\n" 
     5"Project-Id-Version: GS Only PDF Preview 1.0.5\n" 
    66"Report-Msgid-Bugs-To: " 
    77"https://wordpress.org/support/plugin/gs-only-pdf-preview\n" 
     
    2626"X-Textdomain-Support: yes\n" 
    2727 
    28 #: gs-only-pdf-preview.php:93 
     28#: gs-only-pdf-preview.php:98 
    2929#. translators: %s: url to admin plugins page. 
    3030msgid "" 
     
    3535msgstr "" 
    3636 
    37 #: gs-only-pdf-preview.php:99 
     37#: gs-only-pdf-preview.php:106 
    3838#. translators: %s: url to admin plugins page. 
    3939msgid "" 
     
    4343msgstr "" 
    4444 
    45 #: gs-only-pdf-preview.php:112 
    46 #. translators: %s: url to admin plugins page. 
    47 msgid "" 
    48 "The plugin \"GS Only PDF Preview\" cannot be activated as it relies on the " 
    49 "PHP function <code>exec</code>, which has been disabled on your system via " 
    50 "the suhosin extension directive " 
    51 "<code>suhosin.executor.func.blacklist</code>. <a href=\"%s\">Return to " 
    52 "Plugins page.</a>" 
    53 msgstr "" 
    54  
    55 #: gs-only-pdf-preview.php:124 
     45#: gs-only-pdf-preview.php:125 
    5646#. translators: %s: url to admin plugins page. 
    5747msgid "" 
     
    6252msgstr "" 
    6353 
    64 #: gs-only-pdf-preview.php:140 
     54#: gs-only-pdf-preview.php:141 
    6555#. translators: %1$s: lowest compatible WordPress version; %2$s: user's current 
    6656#. WordPress version; %3$s: url to admin plugins page. 
     
    7161msgstr "" 
    7262 
    73 #: gs-only-pdf-preview.php:153 
     63#: gs-only-pdf-preview.php:154 
    7464#. translators: %1$s: highest WordPress version tested; %2$s: user's current 
    7565#. WordPress version. 
     
    7969msgstr "" 
    8070 
    81 #: gs-only-pdf-preview.php:165 
     71#: gs-only-pdf-preview.php:183 gs-only-pdf-preview.php:193 
     72#. translators: %1$s: name of suhosin extension directive; %2$s: url to admin 
     73#. plugins page. 
     74msgid "" 
     75"The plugin \"GS Only PDF Preview\" cannot be activated as it relies on the " 
     76"PHP function <code>exec</code>, which has been disabled on your system via " 
     77"the suhosin extension directive <code>%1$s</code>. <a href=\"%2$s\">Return " 
     78"to Plugins page.</a>" 
     79msgstr "" 
     80 
     81#: gs-only-pdf-preview.php:231 
    8282msgid "" 
    8383"<strong>Warning: no Ghostscript!</strong> The plugin \"GS Only PDF " 
     
    8686msgstr "" 
    8787 
    88 #: gs-only-pdf-preview.php:218 
     88#: gs-only-pdf-preview.php:271 
    8989msgid "Invalid arguments!" 
    9090msgstr "" 
    9191 
    92 #: gs-only-pdf-preview.php:223 
     92#: gs-only-pdf-preview.php:276 
    9393msgid "No PDFs found!" 
    9494msgstr "" 
    9595 
    96 #: gs-only-pdf-preview.php:229 
     96#: gs-only-pdf-preview.php:282 
    9797#. translators: %1$s: formatted number of PDF previews regenerated; %2$s: 
    9898#. formatted number of seconds to one decimal place it took. 
     
    102102msgstr[1] "" 
    103103 
    104 #: gs-only-pdf-preview.php:236 
     104#: gs-only-pdf-preview.php:289 
    105105#. translators: %s: formatted number of non-PDFs ignored. 
    106106msgid "%s non-PDF ignored." 
     
    109109msgstr[1] "" 
    110110 
    111 #: gs-only-pdf-preview.php:241 
     111#: gs-only-pdf-preview.php:294 
    112112msgid "Nothing updated!" 
    113113msgstr "" 
    114114 
    115 #: gs-only-pdf-preview.php:245 
     115#: gs-only-pdf-preview.php:298 
    116116#. translators: %s: formatted number of non-PDFs ignored. 
    117117msgid "Nothing updateable! %s non-PDF ignored." 
     
    120120msgstr[1] "" 
    121121 
    122 #: gs-only-pdf-preview.php:252 
     122#: gs-only-pdf-preview.php:305 
    123123#. translators: %s: formatted number of PDF previews that failed to regenerate. 
    124124msgid "%s PDF preview not regenerated." 
     
    127127msgstr[1] "" 
    128128 
    129 #: gs-only-pdf-preview.php:258 
     129#: gs-only-pdf-preview.php:311 
    130130msgid "You can go again below if you want." 
    131131msgstr "" 
    132132 
    133 #: gs-only-pdf-preview.php:296 gs-only-pdf-preview.php:450 
    134 #: gs-only-pdf-preview.php:544 
     133#: gs-only-pdf-preview.php:349 gs-only-pdf-preview.php:501 
     134#: gs-only-pdf-preview.php:596 
    135135msgid "Regenerate PDF Previews" 
    136136msgstr "" 
    137137 
    138 #: gs-only-pdf-preview.php:296 
     138#: gs-only-pdf-preview.php:349 
    139139msgid "Regen. PDF Previews" 
    140140msgstr "" 
    141141 
    142 #: gs-only-pdf-preview.php:310 gs-only-pdf-preview.php:415 
    143 #: gs-only-pdf-preview.php:615 
     142#: gs-only-pdf-preview.php:363 gs-only-pdf-preview.php:465 
     143#: gs-only-pdf-preview.php:664 
    144144msgid "Sorry, you are not allowed to access this page." 
    145145msgstr "" 
    146146 
    147 #: gs-only-pdf-preview.php:421 
     147#: gs-only-pdf-preview.php:472 
    148148msgid "GS Only PDF Preview - Regenerate PDF Previews" 
    149149msgstr "" 
    150150 
    151 #: gs-only-pdf-preview.php:426 
     151#: gs-only-pdf-preview.php:477 
    152152msgid "" 
    153153"This tool is for regenerating the thumbnail previews of PDFs, but no PDFs " 
     
    155155msgstr "" 
    156156 
    157 #: gs-only-pdf-preview.php:433 
     157#: gs-only-pdf-preview.php:484 
    158158msgid "" 
    159159"<strong>Warning: cannot set max execution time!</strong> The maximum time " 
     
    162162msgstr "" 
    163163 
    164 #: gs-only-pdf-preview.php:442 
     164#: gs-only-pdf-preview.php:493 
    165165msgid "Regenerate the thumbnail previews of PDFs uploaded to your system." 
    166166msgstr "" 
    167167 
    168 #: gs-only-pdf-preview.php:447 
     168#: gs-only-pdf-preview.php:498 
    169169#. translators: %s: formatted number of PDFs found. 
    170170msgid "<strong>%s</strong> PDF has been found." 
     
    173173msgstr[1] "" 
    174174 
    175 #: gs-only-pdf-preview.php:455 
     175#: gs-only-pdf-preview.php:506 
    176176#. translators: %s: formatted number (greater than 10) of PDFs found. 
    177177msgid "Regenerating %s PDF previews can take a long time." 
    178178msgstr "" 
    179179 
    180 #: gs-only-pdf-preview.php:467 
     180#: gs-only-pdf-preview.php:518 
    181181#. translators: %s: url to the Media Library page in list mode. 
    182182msgid "" 
     
    187187msgstr "" 
    188188 
    189 #: gs-only-pdf-preview.php:506 
     189#: gs-only-pdf-preview.php:558 
    190190msgid "Please wait..." 
    191191msgstr "" 
    192192 
    193 #: gs-only-pdf-preview.php:510 
     193#: gs-only-pdf-preview.php:562 
    194194msgid "No items selected!" 
    195195msgstr "" 
    196196 
    197 #: gs-only-pdf-preview.php:511 
     197#: gs-only-pdf-preview.php:563 
    198198msgid "Regenerate Preview ajax action not available!" 
    199199msgstr "" 
    200200 
    201 #: gs-only-pdf-preview.php:515 
     201#: gs-only-pdf-preview.php:567 
    202202msgid "Document Link Only" 
    203203msgstr "" 
    204204 
    205 #: gs-only-pdf-preview.php:599 
     205#: gs-only-pdf-preview.php:649 
    206206#. translators: %s: attachment title 
    207207msgid "Regenerate the PDF preview for &#8220;%s&#8221;" 
    208208msgstr "" 
    209209 
    210 #: gs-only-pdf-preview.php:600 
     210#: gs-only-pdf-preview.php:650 
    211211msgid "Regenerate&nbsp;Preview" 
    212212msgstr "" 
    213213 
    214 #: gs-only-pdf-preview.php:620 
     214#: gs-only-pdf-preview.php:669 
    215215msgid "Invalid nonce." 
    216216msgstr "" 
    217217 
    218 #: gs-only-pdf-preview.php:623 
     218#: gs-only-pdf-preview.php:672 
    219219msgid "Invalid ID." 
    220220msgstr "" 
    221221 
    222 #: gs-only-pdf-preview.php:629 
     222#: gs-only-pdf-preview.php:678 
    223223msgid "Failed to generate the PDF preview." 
    224224msgstr "" 
    225225 
    226 #: gs-only-pdf-preview.php:634 
     226#: gs-only-pdf-preview.php:683 
    227227msgid "" 
    228228"Successfully regenerated the PDF preview. It's best to refresh your browser " 
     
    230230msgstr "" 
    231231 
    232 #: gs-only-pdf-preview.php:636 
     232#: gs-only-pdf-preview.php:685 
    233233msgid "" 
    234234"Successfully regenerated the PDF preview. You will need to refresh your " 
     
    236236msgstr "" 
    237237 
    238 #: gs-only-pdf-preview.php:665 
     238#: gs-only-pdf-preview.php:714 
    239239#. translators: %1$d: percentage of PDF previews completed; %2$d: completed 
    240240#. count. 
     
    242242msgstr "" 
    243243 
    244 #: includes/class-gopp-image-editor-gs.php:161 
     244#: includes/class-gopp-image-editor-gs.php:170 
    245245msgid "Unsupported MIME type." 
    246246msgstr "" 
    247247 
    248 #: includes/class-gopp-image-editor-gs.php:165 
     248#: includes/class-gopp-image-editor-gs.php:174 
    249249msgid "Unsupported destination." 
    250250msgstr "" 
    251251 
    252 #: includes/class-gopp-image-editor-gs.php:172 
     252#: includes/class-gopp-image-editor-gs.php:181 
    253253msgid "No Ghostscript." 
    254254msgstr "" 
    255255 
    256 #: includes/class-gopp-image-editor-gs.php:178 
     256#: includes/class-gopp-image-editor-gs.php:187 
    257257msgid "Image Editor Save Failed" 
    258258msgstr "" 
    259259 
    260 #: includes/class-gopp-image-editor-gs.php:185 
     260#: includes/class-gopp-image-editor-gs.php:192 
    261261msgid "Could not read image size." 
    262262msgstr "" 
    263263 
    264 #: includes/class-gopp-image-editor-gs.php:223 
     264#: includes/class-gopp-image-editor-gs.php:230 
    265265msgid "Loading from URL not supported." 
    266266msgstr "" 
    267267 
    268 #: includes/class-gopp-image-editor-gs.php:228 
    269 #: includes/class-gopp-image-editor-gs.php:234 
     268#: includes/class-gopp-image-editor-gs.php:235 
     269#: includes/class-gopp-image-editor-gs.php:241 
    270270msgid "Unsupported file name." 
    271271msgstr "" 
    272272 
    273 #: includes/class-gopp-image-editor-gs.php:244 
     273#: includes/class-gopp-image-editor-gs.php:251 
    274274msgid "File doesn&#8217;t exist?" 
    275275msgstr "" 
    276276 
    277 #: includes/class-gopp-image-editor-gs.php:251 
     277#: includes/class-gopp-image-editor-gs.php:258 
    278278msgid "File is not a PDF." 
    279279msgstr "" 
    280280 
    281 #: includes/class-gopp-image-editor-gs.php:633 
     281#: includes/class-gopp-image-editor-gs.php:642 
    282282msgid "Attempted to set PDF preview resolution to an invalid value." 
    283283msgstr "" 
    284284 
    285 #: includes/class-gopp-image-editor-gs.php:688 
     285#: includes/class-gopp-image-editor-gs.php:697 
    286286msgid "Attempted to set PDF preview page to an invalid value." 
    287287msgstr "" 
    288288 
    289 #: includes/class-gopp-image-editor-gs.php:707 
    290 #: includes/class-gopp-image-editor-gs.php:728 
    291 #: includes/class-gopp-image-editor-gs.php:747 
    292 #: includes/class-gopp-image-editor-gs.php:760 
    293 #: includes/class-gopp-image-editor-gs.php:774 
    294 #: includes/class-gopp-image-editor-gs.php:787 
     289#: includes/class-gopp-image-editor-gs.php:716 
     290#: includes/class-gopp-image-editor-gs.php:737 
     291#: includes/class-gopp-image-editor-gs.php:756 
     292#: includes/class-gopp-image-editor-gs.php:769 
     293#: includes/class-gopp-image-editor-gs.php:783 
     294#: includes/class-gopp-image-editor-gs.php:796 
    295295msgid "Unsupported operation." 
     296msgstr "" 
     297 
     298#: includes/debug-gopp-image-editor-gs.php:15 
     299msgid "Ghostscript command not found!" 
    296300msgstr "" 
    297301 
  • gs-only-pdf-preview/trunk/readme.txt

    r1594582 r1638565  
    33Tags: Ghostscript, PDF, PDF Preview, Ghostscript Only 
    44Requires at least: 4.7.0 
    5 Tested up to: 4.7.2 
    6 Stable tag: 1.0.4 
     5Tested up to: 4.7.3 
     6Stable tag: 1.0.5 
    77License: GPLv2 or later 
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html 
     
    2424= Limitations = 
    2525 
    26 The plugin requires the PHP function [`exec`](http://php.net/manual/en/function.exec.php) to be enabled on your system. So if the PHP ini setting [`disable_functions`](http://php.net/manual/en/ini.core.php#ini.disable-functions) includes `exec`, the plugin won't work. Neither will it work if the (somewhat outdated) [`suhosin` security extension](https://suhosin.org/stories/index.html) is installed and `exec` is [blacklisted](https://suhosin.org/stories/configuration.html#suhosin-executor-func-blacklist). 
     26The plugin requires the PHP function [`exec`](http://php.net/manual/en/function.exec.php) to be enabled on your system. So if the PHP ini setting [`disable_functions`](http://php.net/manual/en/ini.core.php#ini.disable-functions) includes `exec`, the plugin won't work. Neither will it work if the [`suhosin` security extension](https://suhosin.org/stories/index.html) is installed and `exec` is either not [whitelisted](https://suhosin.org/stories/configuration.html#suhosin-executor-func-whitelist) or is [blacklisted](https://suhosin.org/stories/configuration.html#suhosin-executor-func-blacklist). 
    2727 
    2828Also, the plugin is incompatible with the PHP ini setting [`safe_mode`](http://php.net/manual/en/ini.sect.safe-mode.php#ini.safe-mode), an old (and misnamed) setting that was deprecated in PHP 5.3.0 and removed in PHP 5.4.0. 
     
    3838Unsurprisingly it's faster. Crude benchmarking (see the script [`perf_vs_imagick.php`](https://github.com/gitlost/gs-only-pdf-preview/blob/master/perf/perf_vs_imagick.php)) suggests it's around 35-40% faster. However the production of the preview is only a part of the overhead of uploading a PDF (and doesn't include producing the intermediate thumbnail sizes for instance) so any speed-up may not be that noticeable. 
    3939 
    40 On jpeg thumbnail size it appears to be comparable, maybe a bit larger on average. To mitigate this the default jpeg quality for the PDF preview has been lowered to 70 (from 82), which results in some extra "ringing" (speckles around letters) but the previews tested remain very readable. Note that this only affects the "full" PDF thumbnail - the intermediate-sized thumbnails as produced by `Imagick` or `GD` and any other non-PDF images remain at the standard jpeg quality of 82. Use the WP filter [`wp_editor_set_quality`](https://developer.wordpress.org/reference/hooks/wp_editor_set_quality/) to override this, for instance to restore the quality to 82 you could add to your theme's "functions.php": 
     40= Size = 
     41 
     42On jpeg thumbnail size it appears to be comparable (though it depends on the PDF), maybe a bit larger on average. To mitigate this the default jpeg quality for the PDF preview has been lowered to 70 (from 82), which results in some extra "ringing" (speckles around letters) but the previews tested remain very readable. Note that this only affects the "full" PDF thumbnail - the intermediate-sized thumbnails as produced by `Imagick` or `GD` and any other non-PDF images remain at the standard jpeg quality of 82. You can use the WP filter [`wp_editor_set_quality`](https://developer.wordpress.org/reference/hooks/wp_editor_set_quality/) to override this, for instance to restore the quality to 82 add to your theme's "functions.php": 
    4143 
    4244    function mytheme_wp_editor_set_quality( $quality, $mime_type ) { 
     
    4749    } 
    4850    add_filter( 'wp_editor_set_quality', 'mytheme_wp_editor_set_quality', 10, 2 ); 
     51 
     52= Quality = 
     53 
     54Eyeballing based on very limited data, ie anecdotally, the previews seem to be of superior definition with less artifacts (even with the jpeg quality reduced to 70), and more faithful to the original colours. 
    4955 
    5056= Tool = 
     
    6268A google-cheating schoolboy French translation is supplied. 
    6369 
    64 The plugin runs on WP 4.7.0 to 4.7.2, and requires Ghostscript to be installed on the server. The plugin should run on PHP 5.2.17 to 7.1, and on both Unix and Windows servers. 
     70The plugin runs on WP 4.7.0 to 4.7.3, and requires Ghostscript to be installed on the server. The plugin should run on PHP 5.2.17 to 7.1, and on both Unix and Windows servers. 
    6571 
    6672The project is on [github](https://github.com/gitlost/gs-only-pdf-preview). 
     
    118124    add_filter( 'init', 'mytheme_gopp_init' ); 
    119125 
     126or for [WP-CLI](https://wp-cli.org/) users: 
     127 
     128    wp transient delete gopp_image_gs_cmd_path 
     129 
    120130== Screenshots == 
    121131 
     
    129139 
    130140== Changelog == 
     141 
     142= 1.0.5 (16 Apr 2017) = 
     143* Fix Windows cmd path highest version/best match. 
     144* Set real size not dummy for preview. 
     145* Fix test to be preview name agnostic. 
     146* Remove unnecessary upload_dir calc re old preview thumbnails. 
     147* Insist on mime_type arg in test() to avoid reporting bogus supported implementation. 
     148* Only add actions/filters if have cap. 
     149* Add qunit tests. 
     150* Override get_size() to work if loaded. 
     151* Enable "Alt Text" on Attachment Details. 
     152* WP 4.7.3 compatible 
    131153 
    132154= 1.0.4 (13 Feb 2017) = 
     
    157179== Upgrade Notice == 
    158180 
     181= 1.0.5 = 
     182Determines Windows command path better. 
     183 
    159184= 1.0.4 = 
    160185Allows file names containing "+". 
Note: See TracChangeset for help on using the changeset viewer.