non-attached photos, click-resize (updated 2006 01 17)

Started by Insane Ninja, December 23, 2005, 02:07:27 PM

Previous topic - Next topic

Insane Ninja

UPDATE: check latest post by me

recently i wrote this into my template..

if (stripos($message['body'], 'photobucket.com/albums') !== false)
$message['body'] = preg_replace('#(<img src=")(http://[^\.]+.photobucket.com/albums/[^\.]+/)((?<!th_)[^\/]+\.(jpg|gif))(\"[^>]*>)#i', '$1$2th_$3" onclick="this.src=\'$2$3\';$5', $message['body']);


the idea is to automatically turn photobucket images into their thumbnail versions, where you can click them to return to normal size.. just as attachments do..

i'm asking if theres a better/faster place to put it, thats not in display.template.php


addition:
what would be the best way to revert the image.. i cant find anything about a defaultSrc just yet

dtm.exe

Where do you have it now?  Is it functional?

Insane Ninja

#2
new method.. within /Sources/Display.php

upgraded to work with photobucket, imageshack.us [nofollow], and myspace photos.. weither posted as thumbnails or not

the lines on top of this code block are to show location within the file

// Do the censor thang.
censorText($message['body']);
censorText($message['subject']);

// Run BBC interpreter on the message.
$message['body'] = parse_bbc($message['body'], $message['smileysEnabled'], $message['ID_MSG']);

// Filter photos to thumbnails
if (stripos($message['body'], '.llnwd.net/') !== false)
$message['body'] = preg_replace('#(<img src=")(http://myspace-[0-9]+[^\/]+.llnwd.net/[^\.]+)(?:_[s|m|l])(\.(png|bmp|jpg|gif))(\"[^>]*>)#i', '$1$2_m$3" style="cursor:pointer;cursor:hand;" onclick="this.src=(this.src==\'$2_l$3\'?\'$2_m$3\':\'$2_l$3\');$5', $message['body']);
if (stripos($message['body'], '.imageshack.us/img') !== false)
$message['body'] = preg_replace('#(<img src=")(http://img[0-9]+.imageshack.us/img[^\.]+)(?:\.th)?(\.(png|bmp|jpg|gif))(\"[^>]*>)#i', '$1$2.th$3" style="cursor:pointer;cursor:hand;" onclick="this.src=(this.src==\'$2$3\'?\'$2.th$3\':\'$2$3\');$5', $message['body']);
if (stripos($message['body'], 'photobucket.com/albums') !== false)
$message['body'] = preg_replace('#(<img src=")(http://[^\.]+.photobucket.com/albums/[^\.]+/)(?:th_)?([^\/]+\.(png|bmp|jpg|gif))(\"[^>]*>)#i', '$1$2th_$3" style="cursor:pointer;cursor:hand;" onclick="this.src=(this.src==\'$2$3\'?\'$2th_$3\':\'$2$3\');$5', $message['body']);

Insane Ninja

nobody tested this?

i made it apart of my "usual theme edits" smf mod on my own site.. but its small enough that i'd just call it a tip/trick

SleePy

Quote from: Insane Ninja on January 18, 2006, 08:24:19 PM
nobody tested this?

i made it apart of my "usual theme edits" smf mod on my own site.. but its small enough that i'd just call it a tip/trick

what if somebody didn't make a thumbnail such as imageshack were you don't always get one...
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

Insane Ninja

i dont use imageshack.. i had my friend give me the url to a thumb.. i could put in an onerror code to revert it to the origional form

SleePy

i don't remember were but i saw some were that php can create the thumbnail. could you do that if the thumbnail doesn't exist?
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

Insane Ninja

i do plan to tweak it for hard-coded guest permissions such as replacing images with [guests may not view] or similar

Advertisement: