PDA

View Full Version : Attached images elsewhere within the post


Admin
07-09-2002, 10:00 PM
This is a very basic hack but pretty cool I think...
Anyway, it lets you place your attachments elsewhere in the post, i.e not at the bottom.
All you need to do is place [attachment] where you want it to show up, and voila. :)

Of course this mainly makes sense if you have view images turned on for attachments, so attached images show up inline.
It will also look best if you edit the "postbit_attachmentimage" template and remove the whole "$post[username] has attached this image:" part.

Anyway, installation is really easy, just one file edit. In functions.php, add this code:
$attachpos = strpos($post['message'], '[attachment]');
if ($attachpos !== false) {
$post['message'] = substr($post['message'], 0, $attachpos) . $post['attachment'] . substr($post['message'], $attachpos + strlen('[attachment]'));
$post['attachment'] = '';
}
Right before this:
//highlight words for search engine
if (isset($highlight) && $highlight != '') {

A screen shot is attached...

VeRT3X
07-10-2002, 07:29 PM
perfect, thanks alot Chen = ]

Itworx4me
07-10-2002, 07:41 PM
Squirrel Mall
Webmall for nuts
:p

Vivi Ornitier
07-10-2002, 09:00 PM
gangsta hack man.

Floris
07-10-2002, 09:07 PM
great hack, and so easy!

ehjay
07-11-2002, 12:02 AM
so Chen, are your test posts always full of "assdas"? ;)

plcguru
07-11-2002, 03:20 AM
Hi,
Didn't seem to work for me :disappointed:
I have 2.23 and found the code in fuctions.php
Added the recommended code after it.

posted a test post
like:

some text here.
[attachment]
some text below

attached a gif.

The post looked like:

some text here.
[attachment]
some text below

image down here as usual

Does it work with 2.2.3 and I've done something wrong? (of course, images are turned on as I see the image in the normal place below the text)
I really want to install this as it's a great feature to have.
Thanks!
Phil

Neo
07-11-2002, 04:33 AM
Nice Chen.

RDX1
07-11-2002, 04:59 AM
what if you use the muti attach hack? one of my boards i run uses it - friend made it though..

Admin
07-11-2002, 06:14 AM
plcguru: You might be running a very old version of PHP.

Try replacing this:
if ($attachpos !== false) {
With this:
if (is_integer($attachpos)) {

Velocd
07-11-2002, 07:27 AM
short, simple, but sweet. ;)
Thnx Double F

tractor-beam
07-11-2002, 12:06 PM
This is a GREAT hack, thanks! How would this work for multiple attachments?

Thanks!

Dean C
07-11-2002, 05:06 PM
this is so cool....

plcguru
07-12-2002, 01:58 AM
Originally posted by FireFly
plcguru: You might be running a very old version of PHP.
<snip>


I tried replacing the code as you suggested. No luck. Any other ideas?
Maybe some other hack I have installed might bother this one... like ---New vbcode.js - vBcode and smilie user interface improvement --- ?
Thx,
Phil

Admin
07-12-2002, 05:51 AM
Send me your functions.php by email, I'll take a lookie look.

Stealthy
07-13-2002, 02:05 AM
Not working for me either on 2.2.5

I installed the vbcode.js hack as well.

Admin
07-13-2002, 07:11 AM
Apply it again, my post said AFTER and not BEFORE. :) Sorry.

stryka
09-17-2002, 04:16 PM
Originally posted by tractor-beam
This is a GREAT hack, thanks! How would this work for multiple attachments?

Thanks!

Thanx to LOGICIAN for this link... BUT.... did anyone modify this hack for MULTIPLE ATTACHMENTS

Tim Wheatley
10-26-2002, 04:37 PM
If someone doesn't insert the text, does it go to the default place??

Bison
01-22-2003, 12:43 AM
^^
Good one mates!

Larry@IOG
03-20-2003, 11:31 PM
Hpw can I get the attachment to the left and then starting at the top of the attachment (I have my attachments thumbnailed) to the right start the post?

Thanks

Larry

Gutspiller
07-05-2003, 01:45 AM
I tried to get this hack to work, but it didn't want to. :(

I have

//highlight words for search engine
if (isset($highlight)) {



in my function file, but not


//highlight words for search engine
if (isset($highlight) && $highlight != '') {


Any help? :nervous: