News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

SSI and images...

Started by Jim R, November 13, 2008, 12:21:07 PM

Previous topic - Next topic

Jim R

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)


Jim R


[SiNaN]

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] : '',
Former SMF Core Developer | My Mods | SimplePortal

Jim R

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.

[SiNaN]

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.
Former SMF Core Developer | My Mods | SimplePortal

Advertisement: