Page 1 of 1

[Improvement] Default watermark with overide

Posted: 22 Mar 2009, 15:41
by cordel
Hello,
First I want to say thank you for a clean nice module, loving it so far and can't wait to get it on my server.
I have been playing with it on a test server and is fairly close to what I'm looking for.

I had a need to make sure all photos are watermarked, and also the ability to add a custom watermark as it basically already does except there is not a default per say. So what I have done is added so that Watermarks in images/phocagallery would be default in all subfolders unless the folder has watermark files in it and it will use those. It works for my needs, maybe some others or maybe not. I do okay with PHP but it's not my strong suit, but I thought I would share just in case it's usefull and maybe someone can point out a more appropriate way to code it.

Info:
Phoca Gallery Version: 2.2.3 beta
My changes start at Line 819 in file administrator/components/com_phocagallery/helpers/phocagallery.php

Code: Select all

                                        $fileName                       = PhocaGalleryHelper::getTitleFromFilenameWithExt ($file_in);

                                        // ****Corey add default watermark in image root dir****
                                        // If watermark is in current directory use it else use default
                                        $path=JPATH_ROOT.DS.'images'.DS.'phocagallery';
                                        $fileWatermarkMedium  = str_replace($fileName, 'watermark-medium.png', $file_in);
                                        $fileWatermarkLarge  = str_replace($fileName, 'watermark-large.png', $file_in);
                                        clearstatcache();

                                        // Which Watermark will be used
                                        if ($thumbnailMedium) {
                                                if (file_exists($fileWatermarkMedium)) {
                                                        $fileWatermark  = $fileWatermarkMedium
                                                } else {
                                                        $fileWatermark  = $path.DS.'watermark-medium.png';
                                                }
                                        } else if ($thumbnailLarge) {
                                                if (file_exists($fileWatermarkLarge)) {
                                                        $fileWatermark  = $fileWatermarkLarge
                                                } else {
                                                        $fileWatermark  = $path.DS.'watermark-large.png';
                                                }
                                        } else {
                                                $fileWatermark  = '';
                                        }

So far it works the way I want it too, so just in case it's useful to anyone else. I tried to attach it as a patch file, and txt file put neither appear to be allowed so the above must suffice and I hope it withstands the forum filtering. If it does not work let me know and I can see if I can put the patch somewhere useful.

Re: [Improvement] Default watermark with overide

Posted: 25 Mar 2009, 11:28
by chriddo
This idea is perfect and would suite my needs as well :twisted:

Re: [Improvement] Default watermark with overide

Posted: 25 Mar 2009, 13:17
by Jan
Hi, thank you for this solution, added into feature request list.

Jan