Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Feb 2007
Posts: 329
Yarp™
Yarp™
Offline
Joined: Feb 2007
Posts: 329
I would like it if images are converted to normal links when you quote a message. Quote on quote on quote looks pretty horrible, and with images, even worse.

I have the PHP part...

Just before

Code
		$QuoteBody = "
Originally Posted by $ResUsername
$RawBody
";

in /scripts/newreply.inc.php

add

Code
		$RawBody=preg_replace("#\[img\]([^?\['\"]+?)\.(gif|png|jpg|jpeg)\[/img\]#i", '\1.\2 ',$RawBody);
$RawBody=preg_replace("#\[image\]([^?\['\"]+?)\.(gif|png|jpg|jpeg)\[/image\]#i", '\1.\2 ',$RawBody);
$RawBody=preg_replace("#\[img:(left|right|center)\]([^?\['\"]+?)\.(gif|png|jpg|jpeg)\[/img\]#i", '\2.\3 ',$RawBody);
$RawBody=preg_replace("#\[image:(left|right|center)\]([^?\['\"]+?)\.(gif|png|jpg|jpeg)\[/image\]#i", '\2.\3 ',$RawBody);

But I also need to hack ubb_js/quickquote.js just before the line

Code
			obj.Body.value += '
Originally Posted by ' + quoted + '
' + postBody + '
';

But javascript and me are not best friends (in fact, we met 5 minutes ago laugh ). Can anyone help me port above code to javascript?

Above expressions remove the [img] tags, and add a space behind. Just in case somebody put some images right next to each other.

Sponsored Links
Joined: Nov 2003
Posts: 482
Enthusiast
Enthusiast
Offline
Joined: Nov 2003
Posts: 482
.js support regex too.. well it's midnite here, so i can do that tomorrow..

one thing i did for imgs rather than replace them in quotes was to just make a thumbnail(clickable) instead.. so your replace would just add some height/width to the img..

actually it creates [thumb:xxx,yyy]whatever[/thumb], then do_markup handles the html-izing smile

:2c:

if it ain't 'fixed' by tomorrow, i can supply you with the .js as it's really VERY similar wink

Joined: Nov 2003
Posts: 482
Enthusiast
Enthusiast
Offline
Joined: Nov 2003
Posts: 482
haven't forgotten you blaask.. i got sidetracked frown

Joined: Feb 2007
Posts: 329
Yarp™
Yarp™
Offline
Joined: Feb 2007
Posts: 329
Originally Posted by sirdude
haven't forgotten you blaask.. i got sidetracked frown

My wish come through, some overseas dude says he didn't forget me smile

I'm patient smile

And I think I'd rather strip the tags then replacing it with a thumbnail. I kinda hate thumbnail sized pictures that are in reality big pics. The resize is ugly, and the loading times are still high.

Joined: Nov 2003
Posts: 482
Enthusiast
Enthusiast
Offline
Joined: Nov 2003
Posts: 482
example for first one would be..

Code

var re = "/\[img\]([^?\['\"]+?)\.(gif|png|jpg|jpeg)\[/img\]/i";


postBody = postBody.replace(re,"\1.\2");


i think.. this is from memory..


you also have .match as well..

sorry for quickie post, but i have another thing to do ..

edit.. added 1, 2 capture..

Sponsored Links
Joined: Nov 2003
Posts: 482
Enthusiast
Enthusiast
Offline
Joined: Nov 2003
Posts: 482
oops. forgot the capture into 1 and 2.. /me rewrites..

Joined: Nov 2003
Posts: 482
Enthusiast
Enthusiast
Offline
Joined: Nov 2003
Posts: 482
ps: easy way to test your regex in .js online...

to get it right.. i just found it..

http://www.regular-expressions.info/javascriptexample.html

might help you :2c:

Joined: Feb 2007
Posts: 329
Yarp™
Yarp™
Offline
Joined: Feb 2007
Posts: 329
Originally Posted by sirdude
i think.. this is from memory..


You've been drinking? smile

It doesn't work yet. As I said, no hurries, as long as it's done before the next full moon smile

Joined: Nov 2003
Posts: 482
Enthusiast
Enthusiast
Offline
Joined: Nov 2003
Posts: 482
i hope the next full moon isn't within the next 2hours ! laugh

/me retries later..

Joined: Nov 2003
Posts: 482
Enthusiast
Enthusiast
Offline
Joined: Nov 2003
Posts: 482
try this:

Code

var re = "\[img\]([^?\['\"]+?)\.(gif|png|jpg|jpeg)\[/img\]";
postBody = postBody.replace(re,"$1.$2");

4 times, with re as the different regexes..

Sponsored Links
Joined: Feb 2007
Posts: 329
Yarp™
Yarp™
Offline
Joined: Feb 2007
Posts: 329
Originally Posted by sirdude
try this:


Nope, no go.

Joined: Nov 2003
Posts: 482
Enthusiast
Enthusiast
Offline
Joined: Nov 2003
Posts: 482
ok, you forced me to actually open quickquote.js..

you realise that it's doing an ajax call to quickquote.inc.php ?

so just before the echo $post_body; you can do the same thing in PHP !!!

no need to futz with the .js tipsy

Joined: Feb 2007
Posts: 329
Yarp™
Yarp™
Offline
Joined: Feb 2007
Posts: 329
Originally Posted by sirdude
no need to futz with the .js tipsy


Gotta love no futzing with the .js smile

Found it, and will give it a try smile

Joined: Nov 2003
Posts: 482
Enthusiast
Enthusiast
Offline
Joined: Nov 2003
Posts: 482
cool smile


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
Nettomo
Nettomo
Germany, Bremen
Posts: 417
Joined: November 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)