We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 42802
    • 96 Posts
    Sebastian Zahn | ingroove.uy Reply #1, 10 years, 3 months ago
    Getting this error when trying to view a resource in modx that have album call using Cliche image gallery:

    Error "Fatal error: Cannot redeclare class PhpThumb in /home/.."path"../core/components/cliche/model/cliche/helpers/phpthumb/PhpThumb.inc.php on line 46"

    URL: http://sebastianzahn.com/clientes/cg/proyectos/residenciales/green-village.html

    Attach error Log

    Modx 2.2.10
    Php 5.3
    phpThumbOf 1.4.0

    Any help will be welcome, thanks!
    Sebastián. [ed. note: zzseba last edited this post 10 years, 3 months ago.]
    • Sounds like Cliche loads its own version of PhpThumb, while another version is already loaded (perhaps by using phpthumbof/pthumb/phpthumbsup etc).. Perhaps cliche has an option to not create thumbs on the fly?
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 42802
        • 96 Posts
        Sebastian Zahn | ingroove.uy Reply #3, 10 years, 2 months ago
        Quote from: markh at Feb 04, 2014, 01:22 PM
        Sounds like Cliche loads its own version of PhpThumb, while another version is already loaded (perhaps by using phpthumbof/pthumb/phpthumbsup etc).. Perhaps cliche has an option to not create thumbs on the fly?

        Thanks for your reply. I´ll check out if exist this option.
          • 42802
          • 96 Posts
          Sebastian Zahn | ingroove.uy Reply #4, 10 years, 2 months ago
          I check in System Settings / Cliche and only two settings for change, file max size and file types. Check in Snippets property too, nothing.

          It´s strange, I guess almost all modx sites user phpthumb/thumbof/pthumb for showing thumbnails, it´s weird that exist conflict between them.


          Quote from: markh at Feb 04, 2014, 01:22 PM
          Sounds like Cliche loads its own version of PhpThumb, while another version is already loaded (perhaps by using phpthumbof/pthumb/phpthumbsup etc).. Perhaps cliche has an option to not create thumbs on the fly?
          [ed. note: zzseba last edited this post 10 years, 2 months ago.]
          • Indeed, Cliche does not use the phpthumb embedded with Modx.
            It uses another more recent who happen to share the same name : https://github.com/masterexploder/PHPThumb

            However, I strongly recommend you to switch to Gallery or even better MoreGallery as I don't actively support Cliche for now.
              • 42802
              • 96 Posts
              Sebastian Zahn | ingroove.uy Reply #6, 10 years, 2 months ago
              Thanks for writing Stephane!

              I switch to Gallery by now and it works fine. Cliche have a incredible interface but i can´t get it work so I had to use another option. I intall it in a clean modx install and works like a charm, but when i install phpThumb all galleries I create after throw the error, only the gallery created before install of phpthumb worked fine. Try with pthumb but image+ ( crop images ) don´t worked.

              I will check MoreGallery thiking in my new project.

              Thanks again!

              Sebastián.


              Quote from: lossendae at Feb 07, 2014, 05:55 PM
              Indeed, Cliche does not use the phpthumb embedded with Modx.
              It uses another more recent who happen to share the same name : https://github.com/masterexploder/PHPThumb

              However, I strongly recommend you to switch to Gallery or even better MoreGallery as I don't actively support Cliche for now.
                • 44567
                • 23 Posts
                Hey Sebastian,

                I like Cliche way better than Gallery, because Gallery screws up on mobile templates. It calls a connector class and doesn't link to the absolute/cached image.

                More importantly the interface is way better and Cliche seems more straight forward to me.

                Here's what you gotta do (how I fixed it)

                PhpThumb.inc.php is your problem. PHP is a screwed up language that is unable to handle certain redundancies smiley So what you have to do, is just rename the class and all references to it. Shouldn't be a big deal, luckily it is all contained to the helpers directory and not scattered all across the source code.

                Don't hesitate, this is way easier than it sounds.

                1. rename the class PhpThumb.inc.php to something else, like PhpThumbAlt.inc.php
                2. fix the requireonce statement in ThumbLib.class.php to the name that you changed it to
                3. fix references in the following files:
                core/components/cliche/model/cliche/helpers$ grep PhpThumbAlt * -R
                phpthumb/PhpThumbAlt.inc.php:class PhpThumbAlt
                phpthumb/thumb_plugins/gd_rounded.inc.php:$pt = PhpThumbAlt::getInstance();
                phpthumb/thumb_plugins/gd_reflection.inc.php:$pt = PhpThumbAlt::getInstance();
                phpthumb/thumb_plugins/gd_cropper.inc.php:$pt = PhpThumbAlt::getInstance();
                phpthumb/thumb_plugins/gd_watermark.inc.php:$pt = PhpThumbAlt::getInstance();
                phpthumb/ThumbLib.class.php:require_once THUMBLIB_BASE_PATH . '/PhpThumbAlt.inc.php';
                phpthumb/ThumbLib.class.php: $pt = PhpThumbAlt::getInstance();

                You see all the changes I made in those few files. So you'll probably be able to fix that for now.

                Go for it. It's an easy fix. And all that the Cliche developer needs to do is to give its class a fancy, unique name to fix the issue smiley

                Cheers smiley

                Andreas
                  • 42802
                  • 96 Posts
                  Sebastian Zahn | ingroove.uy Reply #8, 10 years ago
                  Thanks Andreas for your reply!

                  For the project finally i used Gallery, and worked fine. Now, i see your response, and i installed Cliche in a clean modx install, version 2.2.14, and works like a charm. As you said, the interface it´s incredible. I will have in mind your fix if i have trouble.

                  Thanks Again, cheers.

                  Sebastian.
                    • 3749
                    • 24,544 Posts
                    You can also wrap the class in phpthumb.inc.php with:

                    if (! class_exists('ClassName') {
                    
                    
                    }
                    


                    Of course, change 'ClassName' to the name of the actual class declared in the file.
                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting
                      • 44567
                      • 23 Posts
                      Hi Bob,

                      sounds more convenient, yes. PHP is not my weapon of choice, when it comes to any sort of software development - so excuse my (not the) best-practice smiley

                      Anyways, for all the others looking at Cliche as an alternative to Gallery:

                      Cliche screws up on many other occasions, too. I actually managed to get it to not find its galleries any more, even cleaning up the database didn't help. The snippet just kept throwing null-pointer exceptions (call on non-object?), or whatever the PHP equivalent for calls on unassigned objects is.

                      I switched back to Gallery, avoiding their built-in thumbnail generation features by using [[+image_absolute:phpthumbof=`whatnot...`]] so my galleries also get displayed fine on mobile devices.

                      For some weird reason, Gallery does not rewrite or cache any of the modified images. URL will look like this:

                      /assets/components/gallery/connector.php?action=web/phpthumb&w=910&h=400&zc=0&far=&q=90&src=%2Fassets%2Fgallery%2F6%2F52.jpg

                      unless of course you don't use the internal thumbnail generation/resizing functions, but instead the method I mentioned above. For some reason, using the default mechanism will end up in your mobile device not showing any of those images.

                      I love MODx, I really do. But dealing with galleries is always a hassle. Most of the time I can work around it and use getResources to perform whatever the customer needs in a very very neat way. But sometimes customers need actual galleries with random amounts of images needing to be attached to something.

                      Has anybody got some experience with MoreGallery? It's the only thing I could find that does what I want, but I am not willing to pay $25 for it just yet smiley

                      Andreas