PDA

View Full Version : bbcode, <img>, and url generation?



abcdefGARY
08-18-2006, 10:13 PM
hi.

I wasn't sure where to put this topic so since my site is in php, i hope it is correct.

I couldn't find this script anywhere but does anyone know how to generate the bbcode , the <img>, and the direct url for a specific picture that is put in a textbox?

an example would be like photobucket:

[IMG]http://i2.photobucket.com/albums/y23/abcdefgary/photobucket.jpg

thanks everyone in advance

mburt
08-18-2006, 11:04 PM
Hmm.. Whoever invented BBCode wasn't exactly looking for a complicating, well.. I'll even go to say it that it's a language. I don't think complex functions were meant for BBCode :)

abcdefGARY
08-19-2006, 05:29 PM
Hmm.. Whoever invented BBCode wasn't exactly looking for a complicating, well.. I'll even go to say it that it's a language. I don't think complex functions were meant for BBCode :):confused:

abcdefGARY
08-22-2006, 11:39 PM
bump.
still looking for an answer / help
thanks in advance.

Twey
08-22-2006, 11:44 PM
Huh?
<?php
$img = 'http://www.mysite.com/folder/image.png';
$htm = '<img src="' . $img . '">';
$bbc = '' . $img . '';
?>

mburt
08-23-2006, 12:19 AM
I thought you were asking for something more difficult :)

Twey
08-23-2006, 02:24 AM
Nor do we, since you didn't give us any info.

tacmig99
08-23-2006, 02:27 AM
Assuming your using it for a forum, you'll have to hard code it into the php file where all the other BBCodes are located. It's different for each type of forum I think.

abcdefGARY
08-23-2006, 02:31 AM
i think i got it using the code twey provided.

thanks!

motormichael12
11-25-2006, 12:43 AM
mines almost like twey's part...


<?php
$img = 'http://www.mysite.com/folder/image.png';
$htm = '<img src="' . $img . '">';
$bbc = '' . $img . '';
?>

but I would have just done


<?php
$pic = $_POST['pic'];

function here that I dont wanna write

<form name="changepic" action="" method="post">
<input name="pic" size="50" type="text" id="pic">
<input type="submit" name="Submit" value="Submit">
<input name="htm" size= "50" type="text" id="htm" value="<img src='$pic'>">
<input name="bbc" size= "50" type="text" id="bbc" value="$pic>
</form>

that probably wouldn't have worked though.

Twey
11-25-2006, 02:26 PM
Yeah, that's a good idea, although you'd have had to have done
<?php echo($pic); ?>or similar.

motormichael12
11-26-2006, 02:35 AM
yeah you could have done that, taht would have been easier but i wnet with the difficult function...

motormichael12
11-26-2006, 03:04 AM
w00t this ones nice that i just made like in 20 seconds using my original untested script, so I made a succesful one without testing... this ones nice though...


<?php
$pic = $_POST['pic'];
$htm = $_POST['htm'];
$bbc = $_POST['bbc'];

?>
<img src="<?php echo($pic); ?>"><BR><BR>
<form name="changepic" action="" method="post">
<input name="pic" size="50" type="text" id="pic" value="<?php echo($pic); ?>"><BR>
<input type="submit" name="Submit" value="Submit"><BR>
<input name="htm" size= "50" type="text" id="htm" value="<img src='<?php echo($pic); ?>'>"><BR>
<input name="bbc" size= "50" type="text" id="bbc" value="<?php echo($pic); ?>">
</form>

test it on
http://michael.hungerford.us/imgtransfer.php

this one lets you click submit after entering img location on first field, then click submit and it refreshes and puts a preview of the image, the location in the first field, the html version in the second field, and the third field is the bbcode.

This is the first php script I've ever just writeen and it worked on my own, so Im pretty happy about this.

motormichael12
11-26-2006, 03:05 AM
Updated version!


<?php
$pic = $_POST['pic'];
$htm = $_POST['htm'];
$bbc = $_POST['bbc'];

?>
Image Preview:<BR>
<HR WIDTH="100%" SIZE="1" ALIGN="Left" NOSHADE COLOR="#000000">
<img src="<?php echo($pic); ?>"><BR>
<HR WIDTH="100%" SIZE="1" ALIGN="Left" NOSHADE COLOR="#000000"><BR>
<form name="changepic" action="" method="post">
Picture Location: <input name="pic" size="50" type="text" id="pic" value="<?php echo($pic); ?>">
<input type="submit" name="Submit" value="Submit"><BR><BR>
HTML code: <input name="htm" size= "50" type="text" id="htm" value="<img src='<?php echo($pic); ?>'>"><BR>
BBcode: <input name="bbc" size= "50" type="text" id="bbc" value="<?php echo($pic); ?>">
</form>

tech_support
11-28-2006, 02:45 AM
Just remember to strip HTML.

motormichael12
12-02-2006, 02:32 AM
<?php
$pic = $_POST['pic'];
$htm = $_POST['htm'];
$bbc = $_POST['bbc'];

?>
Image Preview:<BR>
<HR WIDTH="100%" SIZE="1" ALIGN="Left" NOSHADE COLOR="#000000">
<?php
if ($pic !=""){
?>
<img src="<?php echo($pic); ?>">
<?php
} else {
?>
<?php } ?>
<BR>
<HR WIDTH="100%" SIZE="1" ALIGN="Left" NOSHADE COLOR="#000000">
<form name="changepic" action="" method="post">
Enter an image's location and this will convert it to HTML code and BBcode.<BR><BR>
Picture Location: <input name="pic" size="50" type="text" id="pic" value="<?php echo($pic); ?>">
<input type="submit" name="Submit" value="Submit"><BR><BR>
<?php
if ($pic !=""){
?>
HTML code: <input name="htm" size= "50" type="text" id="htm" value="<img src='<?php echo($pic); ?>'>"><BR>
BBcode: <input name="bbc" size= "50" type="text" id="bbc" value="<?php echo($pic); ?>">
<?php
} else {
?>
HTML code: <input name="htm" size= "50" type="text" id="htm"><BR>
BBcode: <input name="bbc" size= "50" type="text" id="bbc">
<?php } ?>
</form>

tells description, and img preview... also hides the <img scr=''> and [omg][/img] in fields when the first field is empty