Title: fredd500's Replies | WordPress.org

---

# fredd500

  [  ](https://wordpress.org/support/users/fredd500/)

 *   [Profile](https://wordpress.org/support/users/fredd500/)
 *   [Topics Started](https://wordpress.org/support/users/fredd500/topics/)
 *   [Replies Created](https://wordpress.org/support/users/fredd500/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/fredd500/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/fredd500/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/fredd500/engagements/)
 *   [Favorites](https://wordpress.org/support/users/fredd500/favorites/)

 Search replies:

## Forum Replies Created

Viewing 12 replies - 1 through 12 (of 12 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Document Gallery] Thumbnail generation fails after upgrade to 2.n](https://wordpress.org/support/topic/thumbnail-generation-fails-after-upgrade-to-2n/)
 *  Thread Starter [fredd500](https://wordpress.org/support/users/fredd500/)
 * (@fredd500)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/thumbnail-generation-fails-after-upgrade-to-2n/#post-4788117)
 * Sorry Dan, this doesn’t look like it has fixed it.
 * I deleted the plug in and re-installed it. While the settings screen now performs
   better in that it reliably allows me to enable ghostscript after setting the 
   path which it didn’t before. It still doesn’t generate thumbnails as it should.
 * The reason for this is that the call to getThumbnail() calls self::getThumbers().
   getThumbers() checks whether ghostscript is now active (which it is because I
   set it in the settings screen) then calls getGhostscriptExecutable() which is
   still calling exec(‘which gs’) to find the executable which we know fails.
 * I also had a problem in that after finding that the new version didn’t work I
   patched it as above but the document_gallery options already contained a lot 
   of [‘thumber’][‘thumb’][ID] = false settings. The only way I could clear these
   was to uninstall, re-install, patch then enable the plug-in again. Not often 
   needed perhaps, but how about adding a ‘regenerate thumbnails’ button to the 
   settings screen which will clear out all of these settings forcing the plugin
   to regen. This could also help if a user upgrades ghostscript or chooses to change
   options etc.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Document Gallery] Thumbnail generation fails after upgrade to 2.n](https://wordpress.org/support/topic/thumbnail-generation-fails-after-upgrade-to-2n/)
 *  Thread Starter [fredd500](https://wordpress.org/support/users/fredd500/)
 * (@fredd500)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/thumbnail-generation-fails-after-upgrade-to-2n/#post-4788079)
 * Here’s a proposed patch that uses the user defined path to gs if it exists. After
   applying this patch, I had to go back to my plugin settings and re-save:
 *     ```
       diff -Naur document-gallery.orig/inc/class-thumber.php document-gallery/inc/class-thumber.php
       --- document-gallery.orig/inc/class-thumber.php 2014-04-09 21:26:16.380019000 +0100
       +++ document-gallery/inc/class-thumber.php      2014-04-09 21:30:37.733393756 +0100
       @@ -255,7 +255,8 @@
            * @return bool|str If available, returns exe path. False otherwise.
            */
           public static function getGhostscriptExecutable() {
       -      static $executable = null;
       +      $options = self::getOptions();
       +      $executable = $options['gs'];
   
              if (is_null($executable)) {
                 // we must be able to exec()
       @@ -755,4 +756,4 @@
           }
        }
   
       -?>
       \ No newline at end of file
       +?>
       ```
   
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Document Gallery] Thumbnail generation fails after upgrade to 2.n](https://wordpress.org/support/topic/thumbnail-generation-fails-after-upgrade-to-2n/)
 *  Thread Starter [fredd500](https://wordpress.org/support/users/fredd500/)
 * (@fredd500)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/thumbnail-generation-fails-after-upgrade-to-2n/#post-4788077)
 * Right, I think I am getting somewhere.
 * I am thinking at the moment, that the problem lies in how document-gallery decides
   whether I am able to run Ghostscript. On re-installing the plugin, it failed 
   to detect Ghostscript. I can run it from the command line, but I think that is
   irrelevant. I’m using TSOHost in the UK and I SSH to a different IP address to
   where my web server sits. I think the path on the web server might not be set
   correctly.
 * I defined the path to Ghostscript manually by setting it to the standard gs path
   on linux (and the same as it is on the box I ssh to) /usr/bin/gs.
 * The getGhostscriptThumb function uses $options[‘gs’] to identify the binary to
   call. Since I have set this, it works.
 * The problem lies in the fact that getGhostscriptExecutable() fails because it
   doesn’t appear to reference my setting at all and insists on calling exec(‘which
   gs’). This in turn results in getThumbers() not adding the getGhostscriptThumbnail()
   function to $thumbers and so it is never called. I think the ‘which’ command 
   fails – probably because the path isn’t set or something like that.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Document Gallery] Thumbnail generation fails after upgrade to 2.n](https://wordpress.org/support/topic/thumbnail-generation-fails-after-upgrade-to-2n/)
 *  Thread Starter [fredd500](https://wordpress.org/support/users/fredd500/)
 * (@fredd500)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/thumbnail-generation-fails-after-upgrade-to-2n/#post-4788075)
 * OK. I’m very confused too. I’m using this code:
 * `echo "<p><img src='" . str_replace( WP_CONTENT_DIR, WP_CONTENT_URL, DG_Thumber::
   getGhostscriptThumbnail( 14958 ) ) . "'></p>";`
 * in a template page. It works! The image is displayed and what’s more odd is that
   the image is the first page of the PDF, not the last as I reported earlier!
 * Interestingly (or maybe not) when I run the test code, I end up with .png’s in
   my uploads directory. When I upload attachments through the media interface, 
   I end up with .jpg’s in my uploads directory.
 * I’ve just uninstalled the plug in and re-installed it from a new download so 
   definitely have 2.0.5.
 * I see in the code that it checks to see if a thumbnail has already been generated.
   How does it do that? Where does the existing thumbnail come from? I’m wondering
   whether I could remove all the existing thumbnails from the database effectively
   forcing them to be regenerated.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Document Gallery] Thumbnail generation fails after upgrade to 2.n](https://wordpress.org/support/topic/thumbnail-generation-fails-after-upgrade-to-2n/)
 *  Thread Starter [fredd500](https://wordpress.org/support/users/fredd500/)
 * (@fredd500)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/thumbnail-generation-fails-after-upgrade-to-2n/#post-4788017)
 * I’m making some progress. I haven’t done your last step, but can confirm that
   exec() is available and get_tmp_file() returns the path to the root of my uploads/
   directory.
 * Checking in there, I can see some temporary jpgs. Woohoo. Browsing to them [http://site/wp-content/uploads/md5hashstring.jpg](http://site/wp-content/uploads/md5hashstring.jpg)
   displays a JPG version of the last page* of my PDF. Double WooHoo.
 * So, the issue I guess is either the script is timing out before it completes 
   the move of the temporary file to it’s final resting place, or, for whatever 
   reason, the temporary JPG is created, but it’s path not passed to the function
   which then moves it.
 * * I recall Ghostscript generating a JPG of the last page before. You kindly fixed
   that for me, but I don’t recall how.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Document Gallery] Thumbnail generation fails after upgrade to 2.n](https://wordpress.org/support/topic/thumbnail-generation-fails-after-upgrade-to-2n/)
 *  Thread Starter [fredd500](https://wordpress.org/support/users/fredd500/)
 * (@fredd500)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/thumbnail-generation-fails-after-upgrade-to-2n/#post-4787960)
 * Can’t see anything referring to exec().
 * Is this the bit I’m looking for?
 * “Advanced Thumbnail Generation”
 * Has the method fundamentally changed since 1.x – it was working generally OK (
   an odd few PDF’s failed – probably encrypted or something) but generally OK.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Document Gallery] List media by category](https://wordpress.org/support/topic/list-media-by-category/)
 *  Thread Starter [fredd500](https://wordpress.org/support/users/fredd500/)
 * (@fredd500)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/list-media-by-category/#post-4466611)
 * Martin,
 * I’m using [dg category=fox localpost=false] on my pages and this works well –
   notwithstanding the issues I am now having with Ghostscript not working after
   the upgrade to 2.x.
 * Chris
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Document Gallery] pdf thumbnails instead of generic icon](https://wordpress.org/support/topic/pdf-thumbnails-instead-of-generic-icon/)
 *  [fredd500](https://wordpress.org/support/users/fredd500/)
 * (@fredd500)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/pdf-thumbnails-instead-of-generic-icon/#post-4387948)
 * Dan
 * This works for me now (or at least it did when I removed my modified functions
   from my theme’s functions file – doh!)
 * The only bug that seems to remain is that when deleting attachments, WordPress
   can’t call the deleteThumbMeta function because the util/class-thumber.php isn’t
   included meaning thumbnail files are left in the uploads directory. I’ve fixed
   this with the following patch:
 *     ```
       --- document-gallery.php.orig   2014-01-27 16:23:58.021693657 +0000
       +++ document-gallery.php        2014-01-27 16:29:07.614280523 +0000
       @@ -47,6 +47,10 @@
        add_action('wp_print_styles', 'dg_add_header_css');
   
        // delete thumbnail when attachment is deleted
       -add_action('delete_attachment', array('DG_Thumber', 'deleteThumbMeta'));
       +function dg_delete_thumb( $id ) {
       +       include_once(DG_PATH . 'util/class-thumber.php');
       +       DG_Thumber::deleteThumbMeta($id);
       +}
       +add_action('delete_attachment', 'dg_delete_thumb');
   
       -?>
       \ No newline at end of file
       +?>
       ```
   
 * I hope this is all compliant code, I’m not an experienced PHP or WordPress developer(
   but working on it).
 * One feature I would love to see if you were interested, is an option to always
   include the gallery at the bottom of the post – perhaps implemented with a settings
   page or even better, a widget on the edit page allowing me to select options.
   I’m building a site for an organisation with inexperienced developers and they
   are not going to know what a shortcode is, let alone remember to include it in
   their posts!
 * Hope this helps.
    -Fredd
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Document Gallery] pdf thumbnails instead of generic icon](https://wordpress.org/support/topic/pdf-thumbnails-instead-of-generic-icon/)
 *  [fredd500](https://wordpress.org/support/users/fredd500/)
 * (@fredd500)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/pdf-thumbnails-instead-of-generic-icon/#post-4387939)
 * A couple of things when first viewing a PDF (I haven’t tried other doc types)…
 * What appears to be a temporary thumbnail is created in wp-content/uploads, but
   on my system is a .jpg rather than a .png so the rename fails.
 * Secondly, it appears to be grabbing the last page of the PDF rather than the 
   first – this seems odd behavior to me.
 * `Warning: rename(/var/sites/m/foo/public_html/wp-content/uploads/8a1b42fea5583f1698221cf309b92c010.
   png,/var/sites/m/foo/public_html/wp-content/uploads/2014/01/foo.png) [function.
   rename]: No such file or directory in /var/sites/m/foo/public_html/wp-content/
   plugins/document-gallery/util/class-thumber.php on line 539`
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Document Gallery] pdf thumbnails instead of generic icon](https://wordpress.org/support/topic/pdf-thumbnails-instead-of-generic-icon/)
 *  [fredd500](https://wordpress.org/support/users/fredd500/)
 * (@fredd500)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/pdf-thumbnails-instead-of-generic-icon/#post-4387938)
 * I’m willing to give this new version a go on a site I am still building. Is there
   an easy way of downloading the updated files or do I need to manually download
   each file in turn. Can you tell me which files I need to replace from your stock
   1.4.3 version?
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[bbPress - Mark as Read] Display unread posts only to logged in users](https://wordpress.org/support/topic/display-unread-posts-only-to-logged-in-users/)
 *  Thread Starter [fredd500](https://wordpress.org/support/users/fredd500/)
 * (@fredd500)
 * [12 years, 10 months ago](https://wordpress.org/support/topic/display-unread-posts-only-to-logged-in-users/#post-3915939)
 * Managed to do this myself by editing the plugin code.
 *     ```
       diff --git a/bbp-mark-as-read.php b/bbp-mark-as-read.php
       index b08d0e3..1a79a6d 100644
       --- a/bbp-mark-as-read.php
       +++ b/bbp-mark-as-read.php
       @@ -380,11 +380,15 @@ class BBP_Mark_As_Read {
                       global $post, $user_ID;
                       if( 'topic' != get_post_type( $post ) )
                               return $classes;
       -
       -               if( $this->is_read( $user_ID, $post->ID ) )
       -                       $classes[] = 'bbp-topic-read';
       -               else
       -                       $classes[] = 'bbp-topic-unread';
       +
       +               if( is_user_logged_in() ) {             // Don't bother unless the user is actually logged in - CPM
       +                       if( $this->is_read( $user_ID, $post->ID ) ) {
       +                               $classes[] = 'bbp-topic-read';
       +                       }
       +                       else {
       +                               $classes[] = 'bbp-topic-unread';
       +                       }
       +               }
   
                       return $classes;
               }
       ```
   
 * Any chance this could be incorporated in to the master code?
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[MonsterInsights - Google Analytics Dashboard for WordPress (Website Stats Made Easy)] Does this work with WooCommerce?](https://wordpress.org/support/topic/does-this-work-with-woocommerce/)
 *  [fredd500](https://wordpress.org/support/users/fredd500/)
 * (@fredd500)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/does-this-work-with-woocommerce/#post-3269494)
 * I have a bunch of external/affiliate products on my site at lightwaverfcommunity.
   org.uk. As far as I can see, these links are not tagged with the required onclick
   JS meaning that I cannot (at the moment) create events etc to track these.
 * I’d like to if it is possible.
 * Is this something that could be supported? Could guidance be given on what I 
   need to do to make this work?

Viewing 12 replies - 1 through 12 (of 12 total)