Document Gallery - Version 2.0.6

Version Description

  • Bug Fix: If DG failed to automagically detect the location of the Ghostscript binary, manually setting the location did not enable using it. Thanks for tracking this bug down, Chris!
  • Minor: Included various enhancements in handling thumbnail generation for image types.
  • Tested Up To: Document Gallery has been tested in WP 3.9 (RC 1).
Download this release

Release Info

Developer dan.rossiter
Plugin Icon 128x128 Document Gallery
Version 2.0.6
Comparing to
See all releases

Code changes from version 2.0.5 to 2.0.6

README.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: dan.rossiter
3
  Tags: attachments, thumbnail, documents, gallery, MS office, pdf
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=EE5LWRLG933EN&lc=US&item_name=Document%20Gallery%20Plugin&item_number=document%2dgallery&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
5
  Requires at least: 3.6
6
- Tested up to: 3.8.1
7
- Stable tag: 2.0.5
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -237,7 +237,8 @@ is perfectly alright.
237
 
238
  == Frequently Asked Questions ==
239
 
240
- = Q: Why is -insert thumbnail generation method- enabled on one of my WordPress
 
241
  installs, but not on another one? =
242
 
243
  A: Document Gallery works very hard behind the scenes to ensure that it enables
@@ -297,6 +298,15 @@ Note that the display inherits styling from your active theme.
297
  forum](http://wordpress.org/support/plugin/document-gallery) if you have
298
  ideas)!
299
 
 
 
 
 
 
 
 
 
 
300
  = 2.0.5 =
301
  * **Bug Fix:** Rolling back part of CSS enhancments in 2.0.4 that were causing
302
  errors on some servers. May revisit at a later date.
3
  Tags: attachments, thumbnail, documents, gallery, MS office, pdf
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=EE5LWRLG933EN&lc=US&item_name=Document%20Gallery%20Plugin&item_number=document%2dgallery&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
5
  Requires at least: 3.6
6
+ Tested up to: 3.9
7
+ Stable tag: 2.0.6
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
237
 
238
  == Frequently Asked Questions ==
239
 
240
+
241
+ = Q: Why is [insert thumbnail generation method] enabled on one of my WordPress
242
  installs, but not on another one? =
243
 
244
  A: Document Gallery works very hard behind the scenes to ensure that it enables
298
  forum](http://wordpress.org/support/plugin/document-gallery) if you have
299
  ideas)!
300
 
301
+ = 2.0.6 =
302
+ * **Bug Fix:** If DG failed to automagically detect the location of the
303
+ Ghostscript binary, manually setting the location did not enable using it.
304
+ Thanks for tracking this bug down,
305
+ [Chris](http://wordpress.org/support/profile/fredd500)!
306
+ * **Minor:** Included various enhancements in handling thumbnail generation
307
+ for image types.
308
+ * **Tested Up To:** Document Gallery has been tested in WP 3.9 (RC 1).
309
+
310
  = 2.0.5 =
311
  * **Bug Fix:** Rolling back part of CSS enhancments in 2.0.4 that were causing
312
  errors on some servers. May revisit at a later date.
admin/class-admin.php CHANGED
@@ -190,10 +190,10 @@ class DG_Admin {
190
  'name' => 'thumber_active][gs',
191
  'value' => esc_attr($thumber_active['gs']),
192
  'option_name' => DG_OPTION_NAME,
193
- 'description' => DG_Thumber::getGhostscriptExecutable()
194
  ? __('Use <a href="http://www.ghostscript.com/" target="_blank">Ghostscript</a> for faster local PDF processing (compared to Imagick).', 'document-gallery')
195
  : __('Your server is not configured to run <a href="http://www.ghostscript.com/" target="_blank">Ghostscript</a>.', 'document-gallery'),
196
- 'disabled' => !DG_Thumber::getGhostscriptExecutable()
197
  ));
198
 
199
  add_settings_field(
190
  'name' => 'thumber_active][gs',
191
  'value' => esc_attr($thumber_active['gs']),
192
  'option_name' => DG_OPTION_NAME,
193
+ 'description' => DG_Thumber::isGhostscriptAvailable()
194
  ? __('Use <a href="http://www.ghostscript.com/" target="_blank">Ghostscript</a> for faster local PDF processing (compared to Imagick).', 'document-gallery')
195
  : __('Your server is not configured to run <a href="http://www.ghostscript.com/" target="_blank">Ghostscript</a>.', 'document-gallery'),
196
+ 'disabled' => !DG_Thumber::isGhostscriptAvailable()
197
  ));
198
 
199
  add_settings_field(
document-gallery.php CHANGED
@@ -5,7 +5,7 @@ defined('WPINC') OR exit;
5
  Plugin Name: Document Gallery
6
  Plugin URI: http://wordpress.org/extend/plugins/document-gallery/
7
  Description: Display non-images (and images) in gallery format on a page or post with the [dg] shortcode.
8
- Version: 2.0.5
9
  Author: Dan Rossiter
10
  Author URI: http://danrossiter.org/
11
  License: GPLv2
@@ -13,7 +13,7 @@ defined('WPINC') OR exit;
13
  */
14
 
15
  // define helper paths & URLs
16
- define('DG_VERSION', '2.0.5');
17
  define('DG_URL', plugin_dir_url(__FILE__));
18
  define('DG_PATH', plugin_dir_path(__FILE__));
19
  define('DG_WPINC_PATH', ABSPATH . WPINC . '/');
5
  Plugin Name: Document Gallery
6
  Plugin URI: http://wordpress.org/extend/plugins/document-gallery/
7
  Description: Display non-images (and images) in gallery format on a page or post with the [dg] shortcode.
8
+ Version: 2.0.6
9
  Author: Dan Rossiter
10
  Author URI: http://danrossiter.org/
11
  License: GPLv2
13
  */
14
 
15
  // define helper paths & URLs
16
+ define('DG_VERSION', '2.0.6');
17
  define('DG_URL', plugin_dir_url(__FILE__));
18
  define('DG_PATH', plugin_dir_path(__FILE__));
19
  define('DG_WPINC_PATH', ABSPATH . WPINC . '/');
inc/class-thumber.php CHANGED
@@ -293,6 +293,20 @@ class DG_Thumber {
293
 
294
  return $executable;
295
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
296
 
297
  /*==========================================================================
298
  * GOOGLE DRIVE VIEWER THUMBNAILS
@@ -389,14 +403,16 @@ class DG_Thumber {
389
  * @return str URL to thumbnail.
390
  */
391
  public static function getDefaultThumbnail($ID, $pg = 1) {
 
 
 
392
  $icon_url = DG_URL . 'assets/icons/';
393
 
394
  $url = wp_get_attachment_url($ID);
395
  $ext = self::getExt($url);
396
 
397
  // handle images
398
- if (wp_attachment_is_image($ID) &&
399
- ($icon = wp_get_attachment_image_src($ID, 'thumbnail', false))) {
400
  $icon = $icon[0];
401
  }
402
  // default extension icon
@@ -404,11 +420,8 @@ class DG_Thumber {
404
  $icon = $icon_url . $name;
405
  }
406
  // fallback to standard WP icons
407
- elseif ($icon = wp_get_attachment_image_src($ID, null, true)) {
408
- $icon = $icon[0];
409
- }
410
- // everything failed. This is bad...
411
- else {
412
  $icon = $icon_url . 'missing.png';
413
  }
414
 
@@ -516,11 +529,13 @@ class DG_Thumber {
516
  * + thumb_path - System path to thumbnail image.
517
  * + thumb_url - URL pointing to the thumbnail for this document.
518
  * + thumber - Generator used to create thumb OR false if failed to gen.
519
- * @return array Thumber options from DB.
520
  */
521
  public static function getOptions() {
522
  global $dg_options;
523
- return $dg_options['thumber'];
 
 
524
  }
525
 
526
  /**
@@ -552,7 +567,6 @@ class DG_Thumber {
552
  static $thumbers = false;
553
 
554
  if (false === $thumbers) {
555
- global $wp_version;
556
  $options = self::getOptions();
557
  $active = $options['active'];
558
  $thumbers = array();
293
 
294
  return $executable;
295
  }
296
+
297
+ /**
298
+ * @return bool Whether we can use the GS executable.
299
+ */
300
+ public static function isGhostscriptAvailable() {
301
+ static $ret = null;
302
+
303
+ if (is_null($ret)) {
304
+ $options = self::getOptions();
305
+ $ret = $options['gs'] && self::isExecAvailable();
306
+ }
307
+
308
+ return $ret;
309
+ }
310
 
311
  /*==========================================================================
312
  * GOOGLE DRIVE VIEWER THUMBNAILS
403
  * @return str URL to thumbnail.
404
  */
405
  public static function getDefaultThumbnail($ID, $pg = 1) {
406
+ $options = self::getOptions();
407
+ $width = $options['width'];
408
+ $height = $options['height'];
409
  $icon_url = DG_URL . 'assets/icons/';
410
 
411
  $url = wp_get_attachment_url($ID);
412
  $ext = self::getExt($url);
413
 
414
  // handle images
415
+ if ($icon = image_downsize($ID, array($width, $height))) {
 
416
  $icon = $icon[0];
417
  }
418
  // default extension icon
420
  $icon = $icon_url . $name;
421
  }
422
  // fallback to standard WP icons
423
+ elseif (!$icon = wp_mime_type_icon($ID)) {
424
+ // everything failed. This is bad...
 
 
 
425
  $icon = $icon_url . 'missing.png';
426
  }
427
 
529
  * + thumb_path - System path to thumbnail image.
530
  * + thumb_url - URL pointing to the thumbnail for this document.
531
  * + thumber - Generator used to create thumb OR false if failed to gen.
532
+ * @return array|null Thumber options from DB or null if options not initialized.
533
  */
534
  public static function getOptions() {
535
  global $dg_options;
536
+ return !empty($dg_options) && isset($dg_options['thumber'])
537
+ ? $dg_options['thumber']
538
+ : null;
539
  }
540
 
541
  /**
567
  static $thumbers = false;
568
 
569
  if (false === $thumbers) {
 
570
  $options = self::getOptions();
571
  $active = $options['active'];
572
  $thumbers = array();