6 Replies - 1124 Views - Last Post: 13 December 2011 - 04:08 PM Rate Topic: -----

#1 Boyan   User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 254
  • Joined: 09-September 07

The concept of generating HTML and BBC code for images?

Posted 11 December 2011 - 10:37 AM

Hello everyone,

I have a simple question that might have a not that simple answer, but anyway, hope someone can guide me on this one.

Every image hosting service, offers a link of the uploaded file, shown in a box, with a HTML tags, BBC tags, thumbnail link, etc. I would like to include the same thing on my little project, but I'm not sure where to start.

So, any tutorial link or simple explanation on this matter would be highly appreciated.

Thank you very much!

Is This A Good Question/Topic? 0
  • +

Replies To: The concept of generating HTML and BBC code for images?

#2 codeprada   User is offline

  • Changed Man With Different Priorities
  • member icon

Reputation: 963
  • View blog
  • Posts: 2,382
  • Joined: 15-February 11

Re: The concept of generating HTML and BBC code for images?

Posted 11 December 2011 - 11:46 AM

Hey, look into BBCode. You can start by installing the PECL extension BBCode. Not many functions to work with which is good. It's simple and the documentation should help you out a lot.
Was This Post Helpful? 0
  • +
  • -

#3 Duckington   User is offline

  • D.I.C Addict

Reputation: 172
  • View blog
  • Posts: 615
  • Joined: 12-October 09

Re: The concept of generating HTML and BBC code for images?

Posted 11 December 2011 - 12:04 PM

As long as you have the link to the file, just generate them yourself.

E.g.

// Assuming filepath is in: $filepath
echo "Html: &lt;img src='$filepath' alt='My Image' /&gt;<br>";
echo "BB Code: [*img]$filepath[/*img]<br>"; // Remove the *
// Etc...



All it is is taking the path to the file and displaying it in an HTML <img> tag, a bb code [img] tag, etc...

This post has been edited by Duckington: 11 December 2011 - 12:05 PM

Was This Post Helpful? 1
  • +
  • -

#4 Boyan   User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 254
  • Joined: 09-September 07

Re: The concept of generating HTML and BBC code for images?

Posted 11 December 2011 - 12:12 PM

Thanks Duckington.

That might work. I also though it embedding in a
<textarea></textarea>
tag, which might also come in handy, because the user should be able to copy the image path, embedded between BBC tags.

Basically, I only need to store the image path in a variable (as a string?) and then just echo it.

I'm going to try if this works.

Thanks, it was more simple than I though it was. :)
Was This Post Helpful? 0
  • +
  • -

#5 Boyan   User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 254
  • Joined: 09-September 07

Re: The concept of generating HTML and BBC code for images?

Posted 13 December 2011 - 12:09 PM

First of all, sorry for double post.

Second, I have another question. How can you get the file path, if the file, for an example, a .jpg file, is stored in the DB as a BLOB? The only direct link I can get here from my uploaded images is something like this:

Quote

/path/get.php?id=4


This is what I use to show the uploaded image.

	$image = mysql_query ("SELECT * FROM store WHERE id=$id");
	$image = mysql_fetch_assoc($image);
	$image = $image['image'];
	
	header ("Content-type: image/jpeg");
	
	echo $image;


I know it's a newbiesh example and effort, but that's why I need help. :)

Thank you.
Was This Post Helpful? 0
  • +
  • -

#6 CTphpnwb   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3837
  • View blog
  • Posts: 13,998
  • Joined: 08-August 08

Re: The concept of generating HTML and BBC code for images?

Posted 13 December 2011 - 01:13 PM

If it's stored in the database as a blob, somebody's stored it the wrong way. It has no path.
Was This Post Helpful? 0
  • +
  • -

#7 Boyan   User is offline

  • D.I.C Regular

Reputation: 4
  • View blog
  • Posts: 254
  • Joined: 09-September 07

Re: The concept of generating HTML and BBC code for images?

Posted 13 December 2011 - 04:08 PM

Yep, I'm fixing it. Gonna post about storing images in a new thread if it's not a problem. :) Thank you.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1