The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
Attached Image Watermarking PLUS Guest Viewing of Thumbnails Details »» | |||||||||||||||||||||||||||
Attached Image Watermarking PLUS Guest Viewing of Thumbnails
Developer Last Online: Mar 2012
I had been looking for these two options for quite a while, and was finally able to hire Brian (of vBadvanced) to write them for me. Since a lot of people have been looking for this, I have decided (with Brian's permission) to release this as a free, unsupported, modification.
This modification will allow you to specify a watermark image that will be overlayed over any attached JPG or PNG file on your site in real time, as the image is displayed. NO PERMANENT CHANGES ARE MADE TO ANY OF YOUR ATTACHMENTS. You can also exclude specific forums and usergroups from seeing the watermark. As an added bonus, he included the ability to allow guests to see attached image thumbnails, while still requiring them to register to see the full size attachments. (Make sure you have your Unregistered / Not Logged In usergroup set to NOT have access to download attachments.) PLEASE CLICK INSTALL so that maybe Jelsoft will include these as built-in features in a future version. Notes/Troubleshooting:
Well, on to the modification: ============================================= STEP 1: Since the resulting file contains too much vBulletin code, I am unable to include it with this modification. So, the first step is to copy vBulletin's attachment.php to a file named attachment_watermark.php. Then, edit attachment_watermark.php, making the following changes. ============================================= STEP 2: You need to delete a LOT of lines from the top of the file. Find this line... Code:
$idname = $vbphrase['attachment']; Your attachment_watermark.php file should begin with this code when you've completed this step: Code:
<?php $idname = $vbphrase['attachment']; ============================================= STEP 3: Find this line of code: Code:
if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) OR !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads']) OR !($forumperms & $vbulletin->bf_ugp_forumpermissions['cangetattachment']) OR (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers']) AND ($attachmentinfo['postuserid'] != $vbulletin->userinfo['userid'] OR $vbulletin->userinfo['userid'] == 0))) Code:
if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canview']) OR !($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewthreads']) OR (!($forumperms & $vbulletin->bf_ugp_forumpermissions['cangetattachment']) AND !$vbulletin->GPC['thumb']) OR (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canviewothers']) AND ($attachmentinfo['postuserid'] != $vbulletin->userinfo['userid'] OR $vbulletin->userinfo['userid'] == 0))) ============================================= STEP 4: Find these lines of code: Code:
else { $attachpath = fetch_attachment_path($attachmentinfo['userid'], $attachmentinfo['attachmentid']); Code:
// ######################################### // ##### Start modified section for watermarks // ######################################### $vbulletin->options['attach_water_exforums'] = explode(',', $vbulletin->options['attach_water_exforums']); $vbulletin->options['attach_water_exgroups'] = explode(',', $vbulletin->options['attach_water_exgroups']); if ($vbulletin->options['attach_water_filelocation'] AND in_array($extension, array('jpg', 'jpeg', 'png')) AND !in_array($attachmentinfo['forumid'], $vbulletin->options['attach_water_exforums']) AND !array_intersect(fetch_membergroupids_array($vbulletin->userinfo), $vbulletin->options['attach_water_exgroups']) ) { $attachsize = getimagesize($attachpath); if ($attachsize[0] >= $vbulletin->options['attach_water_minsize'] AND $attachsize[1] >= $vbulletin->options['attach_water_minsize']) { $waterimage =& $vbulletin->options['attach_water_filelocation']; $watersize = getimagesize($waterimage); $waterext = strtolower(substr($waterimage, strrpos($waterimage, '.') + 1)); // Coordinates (height) switch ($vbulletin->options['attach_water_coordinates'][0]) { case 'n': $waterpos['height'] = 0 + $vbulletin->options['attach_water_padding']; break; case 'm': $waterpos['height'] = round(($attachsize[1] - $watersize[1]) / 2); break; case 's': $waterpos['height'] = round(($attachsize[1] - $watersize[1])) - $vbulletin->options['attach_water_padding']; break; } // Coordinates (width) switch ($vbulletin->options['attach_water_coordinates'][1]) { case 'w': $waterpos['width'] = 0 + $vbulletin->options['attach_water_padding']; break; case 'c': $waterpos['width'] = round(($attachsize[0] - $watersize[0]) / 2); break; case 'e': $waterpos['width'] = round(($attachsize[0] - $watersize[0])) - $vbulletin->options['attach_water_padding']; break; } // Watermark ext switch ($waterext) { case 'jpg': case 'jpeg': $watermark = imagecreatefromjpeg($waterimage); break; case 'png': $watermark = imagecreatefrompng($waterimage); break; } // Attachment ext switch ($extension) { case 'jpg': case 'jpeg': $attachimage = imagecreatefromjpeg($attachpath); break; case 'png': $attachimage = imagecreatefrompng($attachpath); break; } imagealphablending($attachimage, true); $watermark_width = imagesx($watermark); $watermark_height = imagesy($watermark); imagecopy($attachimage, $watermark, $waterpos['width'], $waterpos['height'], 0, 0, $watersize[0], $watersize[1]); define('WATERMARKED', true); } } // ######################################### // ##### End modified section for watermarks // ######################################### ============================================= STEP 5: Find this line of code: Code:
header('Content-Length: ' . (($lastbyte + 1) - $startbyte)); Code:
// ######################################### // ##### Start modified section for watermarks // ##### Changed to prevent filesize header on watermarked images // ######################################### if (!defined('WATERMARKED')) { header('Content-Length: ' . (($lastbyte + 1) - $startbyte)); } // ######################################### // ##### End modified section for watermarks // ######################################### ============================================= STEP 6: Find this line of code: Code:
($hook = vBulletinHook::fetch_hook('attachment_display')) ? eval($hook) : false; Code:
// ######################################### // ##### Start modified section for watermarks // ######################################### if (!$vbulletin->GPC['thumb'] AND defined('WATERMARKED')) { imagejpeg($attachimage); imagedestroy($attachimage); imagedestroy($watermark); } // ######################################### // ##### End modified section for watermarks STEP 7: Find this line of code: Code:
($hook = vBulletinHook::fetch_hook('attachment_complete')) ? eval($hook) : false; Code:
exit; ============================================= STEP 8: Save and upload attachment_watermark.php to your forum root directory. ============================================= STEP 9: Install the product-attach_watermark.xml Product via the vBulletin AdminCP Product Manager. ============================================= STEP 10: Configure the options at AdminCP -> vBulletin Options -> Attachment Watermarks. All fields should be self-explanatory. Show Your Support
|
Comments |
#102
|
|||
|
|||
not work for me?
Code:
/usr/www/home/abc/abc.com/images/watermark.png |
#103
|
||||
|
||||
@ConqSoft
Nice hack and thanks for sharing. Works great! |
#104
|
||||
|
||||
@ConqSoft
Can your hack be modify to work with vB-Blog v1.01? |
#105
|
|||
|
|||
hello.. can somebody help me, please..
i've tried to try this cool add ons.. but it doesn't work.. i've followed this script step by step... still no working.. i'm using vbulletin 3.6.8 i've put file attachment_watermark.php into my root forums folder i've put file watermark.png into my images folder.. i've install the product-attach_watermark.xml Product via the vBulletin AdminCP Product Manager. still not working.. what should i type in "Watermark Image Location" if my images. i stored in httpdocs/images folder.. fox example.. my site names is : www.ndut.com now, i type : /ndut.com/httpdocs/images/watermark.png but, doesnt work.. can somebody help me?? thanks before.. |
#106
|
|||
|
|||
I'm using 3.6.8 but it doesn't work. Anybody help me please. Is it work with 3.6.8?
|
#107
|
||||
|
||||
3.6.8 doesn't work, Anybody help us please
|
#108
|
||||
|
||||
Works perfectly fine on 3.6.8 (and 3.6.8 PL1)
|
#109
|
||||
|
||||
I am using it on 3.6.8 PL1 also and it works great, fantastic mod!
|
#110
|
||||
|
||||
How difficult would watermarking the thumbnails be?
I've rewritten some of this to add a second watermark (for smaller images). That worked out nicely. But I've not figured out watermarking thumbs yet. |
#111
|
|||
|
|||
Why bother? thumbs are too small to watermark imho.
|
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
More Information | |
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|