[Improvement] Default watermark with overide

Phoca Gallery - image gallery extension
cordel
Phoca Newbie
Phoca Newbie
Posts: 2
Joined: 22 Mar 2009, 14:45

[Improvement] Default watermark with overide

Post 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.
chriddo
Phoca Member
Phoca Member
Posts: 13
Joined: 16 Mar 2009, 20:41

Re: [Improvement] Default watermark with overide

Post by chriddo »

This idea is perfect and would suite my needs as well :twisted:
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 49297
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: [Improvement] Default watermark with overide

Post by Jan »

Hi, thank you for this solution, added into feature request list.

Jan
If you find Phoca extensions useful, please support the project
Post Reply