SimplePortal

Support => English Support => Topic started by: langel on September 21, 2014, 08:12:54 PM

Title: Extract first image and display block topic
Post by: langel on September 21, 2014, 08:12:54 PM
Hi buddies :)

Today I come with a request, what happens is I want to create a special block and part of its contents is to show the first image of the topic.

Only the first published image of a topic, whether if posted at the beginning or the end of the topic, just extract that image and display it in a block on the portal.

I hope I've given to understand, search the forum but found nothing

Thanks!!
Title: Re: Extract first image and display block topic
Post by: langel on October 09, 2014, 11:43:23 PM
any help here? :(
Title: Re: Extract first image and display block topic
Post by: [SiNaN] on October 11, 2014, 06:43:50 AM
You can use something like the following in a Custom PHP block:

Code: [Select]
$posts = ssi_boardNews(null, null, null, null, 'return');
foreach ($posts as $post)
if (preg_match('~<img src="([^"]+)"[^>]*bbc_img[^"]*" />~', $post['body'], $matches))
echo '<img src="', $matches[1], '" style="max-width: 150px;" alt="" /><br />';
Title: Re: Extract first image and display block topic
Post by: langel on October 12, 2014, 03:05:46 AM
Effectively, extracts the first image of each topic, thanks!

These days I thought, if we can change this part of the block board news:

Code: [Select]
<div class="post"><hr />', $news['body'], '</div>
replace the '$ news [' body '],' by the first image of each topic, I tested the code you gave me, but it shows all the first images of all the topics in that space, which of course, was the request the beginning lol.

Excuse me if I annoy you, is that I have days investigating for smf , but have not found anything, only I have found in wordpress :(

Title: Re: Extract first image and display block topic
Post by: langel on October 14, 2014, 04:39:07 PM
I found this topic: http://www.simplemachines.org/community/index.php?topic=337240.0

The result would be similar to this topic support: http://simpleportal.net/index.php?topic=10766.0

I'll modify a few the SSi boardnews then add it to a block of the portal. It is similar to what I wanted to do.

Thanks for the support   :)
Title: Re: Extract first image and display block topic
Post by: [SiNaN] on October 19, 2014, 03:37:54 PM
Glad that you could find the solution to your request. :)
Title: Re: Extract first image and display block topic
Post by: langel on October 19, 2014, 05:01:59 PM
Thanks so much! :)

This is what I have achieved so far:

(http://i.imgur.com/qDUQ3Br.png)

I'm still working in the blocks that accompany him on the portal, I hope I can finish in a few days.

Regards!
Title: Re: Extract first image and display block topic
Post by: [SiNaN] on October 20, 2014, 03:11:59 AM
That looks really good. Good job!
Title: Re: Extract first image and display block topic
Post by: akshtsaklani7 on October 20, 2014, 09:32:51 AM
Hi langel, this looks pretty awesome...
Title: Re: Extract first image and display block topic
Post by: langel on October 21, 2014, 03:55:38 PM
Thank you [SiNaN] & akshtsaklani7 :)

SimplePortal 2.3.8 © 2008-2024, SimplePortal