UPDATES EasyBlog 6.0.11 Released! Update to the latest version now!

Helpdesk

Your Time
Our Time
Response Time
24 — 48 hours
We strive to provide the fastest ever response possible. However, we are not super beings.

Allow at least 24 — 48 hours
  Support is online
Our support specialists is available now. We will attend to you as soon as we can.
  Support is online
Sometimes, you need to output first attachment image of a discussion in your frontpage.post.php template file.

This how to do it.
First, we are getting the first post attachment

<?php
$attachments = $post->getAttachments();
$attachment = isset( $attachments[ 0 ] ) ? $attachments[ 0 ] : false;
?>



Then we output it inside an image placeholder like this

  <?php if ( $attachment ) {?>
<img src="/<?php echo JURI::root() . 'index.php?option=com_easydiscuss&controller=attachment&task=displayFile&tmpl=component&size=thumb&id=' . $attachment->id;?>">
<?php } else { ?>
<img src="/no_image.jpg">
<?php } ?>


This last code basically check if we have a first attachment to display. If yes, it will display that first attachment, if not it will display a custom "no_image" file

Now, i think this code needs a little bit of tune-up regarding performance.
I was testing it and it seems that the first attachment is not pulled fast.

I think that the code gets ALL attachments and then choose the first one. This could be a problem if we have a lot of attachments inside the post.

So far it works. Maybe some of the team member can confirm that we hit performance problem because we are getting all attachments and then "sort out" the first one instead of getting ONLY the first one.

Whenever you have some spare time guys ... ;)
The replies under this section are restricted to logged in users or users with an active subscription with us