Jump to content
MakeWebGames

Recommended Posts

Posted (edited)

When I first started making the youtube link parser, I had this issue. It suddenly worked, thought it was magic. Turns out I had made changes to the core engine files doh.

To be specific I had moved lines 1385 and 1386 (libs/common.php) to after the Pretty Message hook has ran, and renamed the variables to match up.

RunHook("pretty_message.php", "sourceText");
$sourceText = preg_replace_callback('/(^|[^' . "'" . '])(http(|s):\/\/[a-zA-Z0-9\/\-\+:\.\?=_\&\#\;\%\,]*(\.jpg|\.jpeg|\.gif|\.png))($|[^' . "'" . '])/', "PrettyMessageImageReplace", $sourceText);    
$sourceText = preg_replace_callback('/(^|\s|\>)(http[s]{0,1}:\/\/[a-zA-Z0-9\/\-\+:\.\?=_\&\#\;\%\,]{1,30})([a-zA-Z0-9\/\-\+:\.\?=_\&\#\;\%\,]*)/', "PrettyMessageLinkReplace", $sourceText);

 

Its not fair that the engine calls first dips on changing links and images :p

Edited by Someone
Posted

Sweet, thanks, hope it doesn't crash anything serious :rolleyes:

Haha, I have tested some links, and they still work fine this way around.

Nobody has pointed out that my module dont work with raw youtube links, so no time pressure from me on this.

Posted
I haven't found a youtube use for it yet but I thought it was a great idea. Especially in the future to let players link in 'how to' play type videos.

Greg

It's also handy in profile signatures, for 'profile music' related to their character.

Joan Jett - I love playing with fire, for this little rebel. (on that note who ever removed my Mr Rebel user title here, is a bar-steward.)

Posted
I haven't found a youtube use for it yet but I thought it was a great idea. Especially in the future to let players link in 'how to' play type videos.

Greg

Users like to place videos on their profile, forum posts, messages to each other etc. You got me thinking, videos should perhaps not be in _all_ places where pretty message is used. Might add a setting for that.

The change is needed for just about any change to urls or images, because the hard coded parsing will change it before you can through the hook.

Posted (edited)
well the pretty message hook could provide a "where" parameter and tell you where it's used, and then you decide to act or not.

^That sounds like viable solution.

Tested using this in prettymessage.php

This detected the correct module in profile, messages and forum. But pretty sure it will fail in some cases. Like if you have two pretty messages boxes on one page, and want something only available in one.

$callers = debug_backtrace();
echo $callers[4]['args'][0];
/*
echo '<pre>';
print_r($callers);
echo '</pre>';
*/
Edited by Someone

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...