Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: Jim R on November 13, 2008, 12:21:07 PM

Title: SSI and images...
Post by: Jim R on November 13, 2008, 12:21:07 PM
Using 1.1.4:

There has to be a way to bring an image forward using SSI.  I use my boards to post news stories, and using SSI, I bring them forward to my home page and other pages too.   Let's say I'm set up to bring forward the first 150 characters of the post to my home page, if the first 150 include BBC image code, the picture comes with it, along with text.

There has to be a way to just bring forward the image.  I don't now how to do it...of course, but it just seems like it would be easy.  Like as you're building the array on SSI.php, you'd have:



'image' => (code for a jpg)

Title: Re: SSI and images...
Post by: Jim R on November 16, 2008, 03:04:14 PM
:)  bump
Title: Re: SSI and images...
Post by: [SiNaN] on November 25, 2008, 07:48:40 AM
Hmmm.

This will extract the image:

$images = array();
preg_match_all('/<img[^>]+>/i', parse_bbc($row['body'], 0), $images);


Put it inside the while() loop after the db_query().

Then add this to your array:

'image' => !empty($images[0][0]) ? $images[0][0] : '',
Title: Re: SSI and images...
Post by: Jim R on January 16, 2009, 03:44:31 PM
I apologize for not seeing this response.  Where do I put that code?  How is it utilized? 

I guess my intent is to post an image in a post and only have the image code read by the SSI code.
Title: Re: SSI and images...
Post by: [SiNaN] on January 17, 2009, 11:48:25 AM
If you have followed my instructions, you would have ended up with that. More detailed...

SSI.php

Find:

// If we want to limit the length of the post.

Replace:

$images = array();
preg_match_all('/<img[^>]+>/i', parse_bbc($row['body'], 0), $images);

// If we want to limit the length of the post.


Find:

'locked' => !empty($row['locked']),
'is_last' => false


Replace:

'locked' => !empty($row['locked']),
'is_last' => false,
'image' => !empty($images[0][0]) ? $images[0][0] : '',


Then you will have the 'image' index as the image extacted from the body.