collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 481
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

Installation errors? Mod incompatibilities? Upgrade problems? Make your way over to the Install and Upgrade Support board for all your solutions!

Author Topic: Recent Image Attachments  (Read 10037 times)

0 Members and 2 Guests are viewing this topic.

Offline PADEIRA

  • Semi Newbie
  • *
  • Posts: 12
  • SMF Version: 1.1.12
  • SP Version: 2.3.3
Recent Image Attachments
« on: November 30, 2010, 01:08:23 PM »
good friends ...

I'm battling with the pack of recent images I inserted in my simple portal ...

I want to explain is the following ..

images to appear on I SimplePortal when clicking on the images opens blank page to me only om the picture and I wanted to do click to be directed to the topic where the image is ... it is possible to achieve this?

smf version 1.1.12
SimplePortal 2.3.3 version

thanks

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Recent Image Attachments
« Reply #1 on: November 30, 2010, 02:00:49 PM »
If I understand properly
* You see that clicking on a recent image from the block shows you the attached image
* You desire that clickong on a recent image from the block will show you instead the message it was attached to.
 
--------------
This requires customization of PortalBlocks.php. You can see it gets its items from the SSI function ssi_recentAttachments
 
Code: (find) [Select]
$item['file']['image']['link']
Code: (replace) [Select]
$item['topic']['link']
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline PADEIRA

  • Semi Newbie
  • *
  • Posts: 12
  • SMF Version: 1.1.12
  • SP Version: 2.3.3
Re: Recent Image Attachments
« Reply #2 on: November 30, 2010, 05:27:25 PM »
hello friend did alteration to indicate but the images disappear ..... I wanted to keep the images when clicking on them and enter the topic where it is ....

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Recent Image Attachments
« Reply #3 on: November 30, 2010, 06:44:34 PM »
Oh!  I forgot that part!
 
There are many things about those images available for you to use.
You can see them in SSI.php, in function ssi_recentAttachments
 
I think you can use $item['topic']['href'] for the href part of the link, and $item['file']['image']['link'] $item['file']['image']['href'] for the source of the image.
 
Enjoy!
 
-----------------------
Edit: fixed typo

 
« Last Edit: November 30, 2010, 07:41:32 PM by AngelinaBelle »
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline PADEIRA

  • Semi Newbie
  • *
  • Posts: 12
  • SMF Version: 1.1.12
  • SP Version: 2.3.3
Re: Recent Image Attachments
« Reply #4 on: November 30, 2010, 07:05:22 PM »
is not working .... or am I doing something wrong: (

I have so the code ...
Code: [Select]
function sp_attachmentImage($parameters, $id, $return_parameters = false)
{
global $db_prefix, $modSettings, $scripturl, $txt, $settings, $user_info;

$block_parameters = array(
'limit' => 'int',
'direction' => 'select',
'disablePoster' => 'check',
'disableDownloads' => 'check',
'disableLink' => 'check',
);

if ($return_parameters)
return $block_parameters;

$limit = empty($parameters['limit']) ? 5 : (int) $parameters['limit'];
$direction = empty($parameters['direction']) ? 0 : 1;
$type = array('jpg', 'png', 'gif', 'bmp');
$boards = boardsAllowedTo('view_attachments');
$showPoster = empty($parameters['disablePoster']);
$showDownloads = empty($parameters['disableDownloads']);
$showLink = empty($parameters['disableLink']);

if (empty($boards))
{
echo '
', $txt['error_sp_no_attachments_found'];
return;
}
elseif ($boards[0] == 0)
$boards = '';
else
$boards = ' AND m.ID_BOARD IN (' . implode(',', $boards) . ')';

$request = db_query("
SELECT
att.ID_ATTACH, att.ID_MSG, att.filename, IFNULL(att.size, 0) AS filesize, att.downloads, mem.ID_MEMBER,
IFNULL(mem.realName, m.posterName) AS posterName, m.ID_TOPIC, m.subject, t.ID_BOARD, m.posterTime,
att.width, att.height" . (empty($modSettings['attachmentShowImages']) || empty($modSettings['attachmentThumbnails']) ? "" : ", IFNULL(thumb.ID_ATTACH, 0) AS id_thumb, thumb.width AS thumb_width, thumb.height AS thumb_height") . "
FROM {$db_prefix}attachments AS att
INNER JOIN {$db_prefix}messages AS m ON (m.ID_MSG = att.ID_MSG)
INNER JOIN {$db_prefix}topics AS t ON (t.ID_TOPIC = m.ID_TOPIC)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.ID_MEMBER)" . (empty($modSettings['attachmentShowImages']) || empty($modSettings['attachmentThumbnails']) ? "" : "
LEFT JOIN {$db_prefix}attachments AS thumb ON (thumb.ID_ATTACH = att.ID_THUMB)") . "
LEFT JOIN {$db_prefix}boards AS b ON (b.ID_BOARD = t.ID_BOARD)
WHERE att.attachmentType = 0
AND att.width != 0
AND $user_info[query_see_board]
$boards
ORDER BY att.ID_ATTACH DESC
LIMIT $limit", __FILE__, __LINE__);
$items = array();
while ($row = mysql_fetch_assoc($request))
{
$filename = preg_replace('~&amp;#(\\d{1,7}|x[0-9a-fA-F]{1,6});~', '&#\\1;', htmlspecialchars($row['filename']));

$items[$row['ID_ATTACH']] = array(
'member' => array(
'id' => $row['ID_MEMBER'],
'name' => $row['posterName'],
'link' => empty($row['ID_MEMBER']) ? $row['posterName'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_MEMBER'] . '">' . $row['posterName'] . '</a>',
),
'file' => array(
'filename' => $filename,
'filesize' => round($row['filesize'] /1024, 2) . $txt['smf211'],
'downloads' => $row['downloads'],
'href' => $scripturl . '?action=dlattach;topic=' . $row['ID_TOPIC'] . '.0;attach=' . $row['ID_ATTACH'],
'link' => '<img src="' . $settings['images_url'] . '/icons/clip.gif" alt="" /> <a href="' . $scripturl . '?action=dlattach;topic=' . $row['ID_TOPIC'] . '.0;attach=' . $row['ID_ATTACH'] . '">' . $filename . '</a>',
'is_image' => !empty($row['width']) && !empty($row['height']) && !empty($modSettings['attachmentShowImages']),
),
'topic' => array(
'id' => $row['ID_TOPIC'],
'subject' => $row['subject'],
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#msg' . $row['ID_MSG'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['ID_MSG'] . '#msg' . $row['ID_MSG'] . '">' . $row['subject'] . '</a>',
'time' => timeformat($row['posterTime']),
),
);

if ($items[$row['ID_ATTACH']]['file']['is_image'])
{
$id_thumb = empty($row['ID_THUMB']) ? $row['ID_ATTACH'] : $row['ID_THUMB'];
$items[$row['ID_ATTACH']]['file']['image'] = array(
'id' => $id_thumb,
'width' => $row['width'],
'height' => $row['height'],
'img' => '<img src="' . $scripturl . '?action=dlattach;topic=' . $row['ID_TOPIC'] . '.0;attach=' . $row['ID_ATTACH'] . ';image" alt="' . $filename . '" />',
'thumb' => '<img src="' . $scripturl . '?action=dlattach;topic=' . $row['ID_TOPIC'] . '.0;attach=' . $id_thumb . ';image" alt="' . $filename . '" />',
'href' => $scripturl . '?action=dlattach;topic=' . $row['ID_TOPIC'] . '.0;attach=' . $id_thumb . ';image',
'link' => '<a href="' . $scripturl . '?action=dlattach;topic=' . $row['ID_TOPIC'] . '.0;attach=' . $row['ID_ATTACH'] . ';image"><img src="' . $scripturl . '?action=dlattach;topic=' . $row['ID_TOPIC'] . '.0;attach=' . $id_thumb . ';image" alt="' . $filename . '"' . (empty($row['ID_THUMB']) ? ' width="225"' : '') . ' /></a>',
);
}
}
mysql_free_result($request);

if (empty($items))
{
echo '
', $txt['error_sp_no_attachments_found'];
return;
}

$colorids = array();
foreach ($items as $item)
$colorids[] = $item['member']['id'];

if (!empty($colorids) && sp_loadColors($colorids) !== false)
{
foreach ($items as $k => $p)
{
if (!empty($color_profile[$p['member']['id']]['link']))
$items[$k]['member']['link'] = $color_profile[$p['member']['id']]['link'];
}
}

echo '
<table class="sp_auto_align">', $direction ? '
<tr>' : '';

foreach ($items as $item)
{
  echo !$direction ? '
<tr>' : '', '
<td>
<div class="sp_image smalltext">', ($showLink ? '
<a href="' . $item['topic']['link'] . '">' . $item['file']['filename'] . '</a><br />' : ''), '
', $item['file']['image']['link'], '<br />', ($showDownloads ? '
' . $txt['sp-downloadsCount'] . ': ' . $item['file']['downloads'] . '<br />' : ''), ($showPoster ? '
' . $txt['sp-downloadsPoster'] . ': ' . $item['member']['link'] : ''), '
</div>
</td>', !$direction ? '
</tr>' : '';
}

echo $direction ? '
</tr>' : '', '
</table>';
}

« Last Edit: November 30, 2010, 07:07:39 PM by PADEIRA »

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Recent Image Attachments
« Reply #5 on: November 30, 2010, 07:40:17 PM »
You don't need to copy code in from SSI.php. Why reinvent what function ssi_recentattachments is already doing?
I only look at it to find out what it sends back to the calling function. That is how I found which elements of $items are available to use in sp_recentAttachments.
 
Perhaps something like the code below (warning: untested)
Code: [Select]
           <div class="sp_image smalltext">', ($showLink ? '
            <a href="' . $item['file']['href'] . '">' . $item['file']['filename'] . '</a><br />' : ''), '
            ', <a href=". $item['topic']['href'] . "><img src=" .  $item['topic']['href']. '"></a><br />', ($showDownloads ? '
            ' . $txt['downloads'] . ': ' . $item['file']['downloads'] . '<br />' : ''), ($showPoster ? '
            ' . $txt['posted_by'] . ': ' . $item['member']['link'] : ''), '
           </div>
« Last Edit: November 30, 2010, 07:48:05 PM by AngelinaBelle »
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline PADEIRA

  • Semi Newbie
  • *
  • Posts: 12
  • SMF Version: 1.1.12
  • SP Version: 2.3.3
Re: Recent Image Attachments
« Reply #6 on: December 01, 2010, 12:09:08 PM »
Parse error: syntax error, unexpected '<' in C:\xampp\htdocs\mig\Sources\PortalBlocks.php on line 1681 :(

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Recent Image Attachments
« Reply #7 on: December 01, 2010, 12:48:21 PM »
You really have to squint to spot these.  That's why the line numbers are so useful.
Code: (find) [Select]
           <div class="sp_image smalltext">', ($showLink ? '
            <a href="' . $item['file']['href'] . '">' . $item['file']['filename'] . '</a><br />' : ''), '
            ', $item['file']['image']['link'], '<br />', ($showDownloads ? '
Code: (replace) [Select]
           <div class="sp_image smalltext">', ($showLink ? '
            <a href="' . $item['file']['href'] . '">' . $item['file']['filename'] . '</a><br />' : ''), '
            ', '<a href="' . $item['topic']['href'] . '"><img src="' .  $item['topic']['href']. ''"></a><br />', ($showDownloads ? '

 
Again -- untested.  I leave the remaining testing as an exercise for the reader.
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline PADEIRA

  • Semi Newbie
  • *
  • Posts: 12
  • SMF Version: 1.1.12
  • SP Version: 2.3.3
Re: Recent Image Attachments
« Reply #8 on: December 01, 2010, 01:11:10 PM »
Good AngelinaBelle

yes I have found the code without problems ..... I have made the changes but now the images do not appear ....

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Recent Image Attachments
« Reply #9 on: December 01, 2010, 01:56:56 PM »
I am trying to go to fast.  Of course, where I have put
Code: [Select]
<img src="' .  $item['topic']['href']. ''"> it should be
Code: [Select]
<img src="' .  $item['file']['image']['href']. ''">
Or, perhaps even
Code: [Select]
$item['file']['image']['img']
You should experiment with this different things and see which you like best.
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline PADEIRA

  • Semi Newbie
  • *
  • Posts: 12
  • SMF Version: 1.1.12
  • SP Version: 2.3.3
Re: Recent Image Attachments
« Reply #10 on: December 01, 2010, 02:12:55 PM »
Hello AngelinaBelle

with this code
Code: [Select]
$item['file']['image']['img']
worked ... appeared the image and directs me to the topic where it is now but another headache .... the image appeared to me the actual size of these images in the block in the block that was reduced to 225

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Recent Image Attachments
« Reply #11 on: December 01, 2010, 11:40:15 PM »
Do you have portal image resizing turned on?
Or would you prefer to use the thumbnail size image?
Code: [Select]
<img src="' .  $item['file']['image']['thumb']. ''">
There are so many possiblities.
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline PADEIRA

  • Semi Newbie
  • *
  • Posts: 12
  • SMF Version: 1.1.12
  • SP Version: 2.3.3
Re: Recent Image Attachments
« Reply #12 on: December 02, 2010, 09:27:16 AM »
hello AngelinaBelle

I have images in the portal code scaled well as presents the code below ...

Code: [Select]
      if ($items[$row['ID_ATTACH']]['file']['is_image'])
      {
         $id_thumb = empty($row['ID_THUMB']) ? $row['ID_ATTACH'] : $row['ID_THUMB'];
         $items[$row['ID_ATTACH']]['file']['image'] = array(
            'id' => $id_thumb,
            'width' => $row['width'],
            'height' => $row['height'],
            'img' => '<img src="' . $scripturl . '?action=dlattach;topic=' . $row['ID_TOPIC'] . '.0;attach=' . $row['ID_ATTACH'] . ';image" alt="' . $filename . '" />',
            'thumb' => '<img src="' . $scripturl . '?action=dlattach;topic=' . $row['ID_TOPIC'] . '.0;attach=' . $id_thumb . ';image" alt="' . $filename . '" />',
            'href' => $scripturl . '?action=dlattach;topic=' . $row['ID_TOPIC'] . '.0;attach=' . $id_thumb . ';image',
            'link' => '<a href="' . $scripturl . '?action=dlattach;topic=' . $row['ID_TOPIC'] . '.0;attach=' . $row['ID_ATTACH'] . ';image"><img src="' . $scripturl . '?action=dlattach;topic=' . $row['ID_TOPIC'] . '.0;attach=' . $id_thumb . ';image" alt="' . $filename . '"' . (empty($row['ID_THUMB']) ? ' width="225"' : '') . ' /></a>',
         );


the problem is that the alterations made to me they appear normal in size .... and not as it is configured in the portal code ....

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Recent Image Attachments
« Reply #13 on: December 02, 2010, 03:53:41 PM »
Let's go back to the beginning.  Please start with a fresh copy of PortalBlocks.php.
Do not add any code from SSI.php. Only use what the function ssi_recentAttachments provides to you.
Code: (find in portalblocks.php) [Select]
$item['file']['image']['link']
Code: (replace in portalblocks.php) [Select]
'<a href="',  $item['topic']['href'],  '"><img src="', $item['file']['image']['thumb'],  '"></a>'
You can just LOOK in ssi_recentAttachments to see what it is putting into each of those array elements.
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline PADEIRA

  • Semi Newbie
  • *
  • Posts: 12
  • SMF Version: 1.1.12
  • SP Version: 2.3.3
Re: Recent Image Attachments
« Reply #14 on: December 02, 2010, 05:26:31 PM »
ello friend ...
I have done as thou hast commanded but something is wrong ....

I'll send you my files portalblocks.php you to confirm if you please ....
Ouvir
Ler foneticamente

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Recent Image Attachments
« Reply #15 on: December 02, 2010, 08:13:42 PM »
Code: [Select]
function sp_attachmentImage($parameters, $id, $return_parameters = false)
{
 global $boarddir, $txt, $color_profile;
 $block_parameters = array(
  'limit' => 'int',
  'direction' => 'select',
  'disablePoster' => 'check',
  'disableDownloads' => 'check',
  'disableLink' => 'check',
 );
 if ($return_parameters)
  return $block_parameters;
 $limit = empty($parameters['limit']) ? 5 : (int) $parameters['limit'];
 $direction = empty($parameters['direction']) ? 0 : 1;
 $type = array('jpg', 'png', 'gif', 'bmp');
 $showPoster = empty($parameters['disablePoster']);
 $showDownloads = empty($parameters['disableDownloads']);
 $showLink = empty($parameters['disableLink']);
 $items = ssi_recentAttachments($limit, $type, 'array');
 if (empty($items))
 {
  echo '
        ', $txt['error_sp_no_attachments_found'];
  return;
 }
 $colorids = array();
 foreach ($items as $item)
  $colorids[] = $item['member']['id'];
 if (!empty($colorids) && sp_loadColors($colorids) !== false)
 {
  foreach ($items as $k => $p)
  {
   if (!empty($color_profile[$p['member']['id']]['link']))
    $items[$k]['member']['link'] = $color_profile[$p['member']['id']]['link'];
  }
 }
 echo '
        <table class="sp_auto_align">', $direction ? '
         <tr>' : '';
 foreach ($items as $item)
 {
   echo !$direction ? '
         <tr>' : '', '
          <td>
           <div class="sp_image smalltext">', ($showLink ? '
            <a href="' . $item['file']['href'] . '">' . $item['file']['filename'] . '</a><br />' : ''), '
            ', <a href="',  $item['topic']['href'],  '"><img src="', $item['file']['image']['thumb'],  '"></a>,  // the change is in this line.
            '<br />', ($showDownloads ? '
            ' . $txt['downloads'] . ': ' . $item['file']['downloads'] . '<br />' : ''), ($showPoster ? '
            ' . $txt['posted_by'] . ': ' . $item['member']['link'] : ''), '
           </div>
          </td>', !$direction ? '
         </tr>' : '';
 }
 echo $direction ? '
         </tr>' : '', '
        </table>';
}

Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline PADEIRA

  • Semi Newbie
  • *
  • Posts: 12
  • SMF Version: 1.1.12
  • SP Version: 2.3.3
Re: Recent Image Attachments
« Reply #16 on: December 03, 2010, 12:18:51 PM »
Code: [Select]
function sp_attachmentImage($parameters, $id, $return_parameters = false)
{
 global $boarddir, $txt, $color_profile;
 $block_parameters = array(
  'limit' => 'int',
  'direction' => 'select',
  'disablePoster' => 'check',
  'disableDownloads' => 'check',
  'disableLink' => 'check',
 );
 if ($return_parameters)
  return $block_parameters;
 $limit = empty($parameters['limit']) ? 5 : (int) $parameters['limit'];
 $direction = empty($parameters['direction']) ? 0 : 1;
 $type = array('jpg', 'png', 'gif', 'bmp');
 $showPoster = empty($parameters['disablePoster']);
 $showDownloads = empty($parameters['disableDownloads']);
 $showLink = empty($parameters['disableLink']);
 $items = ssi_recentAttachments($limit, $type, 'array');
 if (empty($items))
 {
  echo '
        ', $txt['error_sp_no_attachments_found'];
  return;
 }
 $colorids = array();
 foreach ($items as $item)
  $colorids[] = $item['member']['id'];
 if (!empty($colorids) && sp_loadColors($colorids) !== false)
 {
  foreach ($items as $k => $p)
  {
   if (!empty($color_profile[$p['member']['id']]['link']))
    $items[$k]['member']['link'] = $color_profile[$p['member']['id']]['link'];
  }
 }
 echo '
        <table class="sp_auto_align">', $direction ? '
         <tr>' : '';
 foreach ($items as $item)
 {
   echo !$direction ? '
         <tr>' : '', '
          <td>
           <div class="sp_image smalltext">', ($showLink ? '
            <a href="' . $item['file']['href'] . '">' . $item['file']['filename'] . '</a><br />' : ''), '
            ', <a href="',  $item['topic']['href'],  '"><img src="', $item['file']['image']['thumb'],  '"></a>,  // the change is in this line.
            '<br />', ($showDownloads ? '
            ' . $txt['downloads'] . ': ' . $item['file']['downloads'] . '<br />' : ''), ($showPoster ? '
            ' . $txt['posted_by'] . ': ' . $item['member']['link'] : ''), '
           </div>
          </td>', !$direction ? '
         </tr>' : '';
 }
 echo $direction ? '
         </tr>' : '', '
        </table>';
}


Parse error: syntax error, unexpected '<' in C:\xampp\htdocs\mig\Sources\PortalBlocks.php on line 1601

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Recent Image Attachments
« Reply #17 on: December 03, 2010, 05:05:19 PM »
Code: [Select]
function sp_attachmentImage($parameters, $id, $return_parameters = false)
{
 global $boarddir, $txt, $color_profile;
 $block_parameters = array(
  'limit' => 'int',
  'direction' => 'select',
  'disablePoster' => 'check',
  'disableDownloads' => 'check',
  'disableLink' => 'check',
 );
 if ($return_parameters)
  return $block_parameters;
 $limit = empty($parameters['limit']) ? 5 : (int) $parameters['limit'];
 $direction = empty($parameters['direction']) ? 0 : 1;
 $type = array('jpg', 'png', 'gif', 'bmp');
 $showPoster = empty($parameters['disablePoster']);
 $showDownloads = empty($parameters['disableDownloads']);
 $showLink = empty($parameters['disableLink']);
 $items = ssi_recentAttachments($limit, $type, 'array');
 if (empty($items))
 {
  echo '
        ', $txt['error_sp_no_attachments_found'];
  return;
 }
 $colorids = array();
 foreach ($items as $item)
  $colorids[] = $item['member']['id'];
 if (!empty($colorids) && sp_loadColors($colorids) !== false)
 {
  foreach ($items as $k => $p)
  {
   if (!empty($color_profile[$p['member']['id']]['link']))
    $items[$k]['member']['link'] = $color_profile[$p['member']['id']]['link'];
  }
 }
 echo '
        <table class="sp_auto_align">', $direction ? '
         <tr>' : '';
 foreach ($items as $item)
 {
   echo !$direction ? '
         <tr>' : '', '
          <td>
           <div class="sp_image smalltext">', ($showLink ? '
            <a href="' . $item['file']['href'] . '">' . $item['file']['filename'] . '</a><br />' : ''), '
            <a href="',  $item['topic']['href'],  '"><img src="', $item['file']['image']['thumb'],  '"></a>,  // the change is in this line.
            '<br />', ($showDownloads ? '
            ' . $txt['downloads'] . ': ' . $item['file']['downloads'] . '<br />' : ''), ($showPoster ? '
            ' . $txt['posted_by'] . ': ' . $item['member']['link'] : ''), '
           </div>
          </td>', !$direction ? '
         </tr>' : '';
 }
 echo $direction ? '
         </tr>' : '', '
        </table>';
}

Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline Chas

  • Jr. Member
  • **
  • Posts: 74
  • Gender: Male
    • Fifty Plus Forum
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Re: Recent Image Attachments
« Reply #18 on: December 13, 2012, 02:33:32 PM »
Sorry to reopen an old topic but I need to do the same thing, essentially click the image(s) on the block takes the user to the topic where the image is posted.

Have tried applying Angelina's mods as above but they result in white screens. Can anyone provide full code changes for 2.3.5 codebase to enable this feature.

No guests have access only members.

Thanks

Chas.

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Recent Image Attachments
« Reply #19 on: January 05, 2013, 05:04:46 PM »
I am not quite certain why this failed, and have not had time to test.
Have you looked at the HTML for that page to see where it has gone wrong?

Perhaps it would be best to abandon that supplied subroutine, and go back to the general idea
Code: (find in portalblocks.php) [Select]
$item['file']['image']['link']
Code: (replace in portalblocks.php) [Select]
'<a href="',  $item['topic']['href'],  '"><img src="', $item['file']['image']['thumb'],  '"></a>'

It seems to me this should still work, even if there are errors in the subroutine I supplied.

My apologies for supplying bad code.
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline velorooms

  • Jr. Member
  • **
  • Posts: 83
    • Velorooms
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: Recent Image Attachments
« Reply #20 on: January 05, 2013, 07:58:54 PM »
Here is the code from my sources/portalblocks.php

from the start of attachment image, to the start of the next block.

Code: [Select]
function sp_attachmentImage($parameters, $id, $return_parameters = false)
{
global $boarddir, $txt, $color_profile;

$block_parameters = array(
'limit' => 'int',
'direction' => 'select',
'disablePoster' => 'check',
'disableDownloads' => 'check',
'disableLink' => 'check',
);

if ($return_parameters)
return $block_parameters;

$limit = empty($parameters['limit']) ? 5 : (int) $parameters['limit'];
$direction = empty($parameters['direction']) ? 0 : 1;
$type = array('jpg', 'png', 'gif', 'bmp');
$showPoster = empty($parameters['disablePoster']);
$showDownloads = empty($parameters['disableDownloads']);
$showLink = empty($parameters['disableLink']);

$items = ssi_recentAttachments($limit, $type, 'array');

if (empty($items))
{
echo '
', $txt['error_sp_no_attachments_found'];
return;
}

$colorids = array();
foreach ($items as $item)
$colorids[] = $item['member']['id'];

if (!empty($colorids) && sp_loadColors($colorids) !== false)
{
foreach ($items as $k => $p)
{
if (!empty($color_profile[$p['member']['id']]['link']))
$items[$k]['member']['link'] = $color_profile[$p['member']['id']]['link'];
}
}

echo '
<table class="sp_auto_align">', $direction ? '
<tr>' : '';

foreach ($items as $item)
{
  echo !$direction ? '
<tr>' : '', '
<td>
<div class="sp_image smalltext">', ($showLink ? '
<a href="' . $item['file']['href'] . '">' . $item['file']['filename'] . '</a><br />' : ''), '
<a href="' . $item['topic']['href'] . '">', $item['file']['image']['thumb'], '</a> <br />', ($showDownloads ? '
' . $txt['downloads'] . ': ' . $item['file']['downloads'] . '<br />' : ''), ($showPoster ? '
' . $txt['posted_by'] . ': ' . $item['member']['link'] : ''), '
</div>
</td>', !$direction ? '
</tr>' : '';
}

echo $direction ? '
</tr>' : '', '
</table>';
}

function sp_attachmentRecent($parameters, $id, $return_parameters = false)

Havnt looked in depth at what we changed, but that does exactly what it should, if you click on the image you are taken to the post in question.

You can view it live on the myhomepage.
Admin and Owner of Velorooms.com - Using SMF 2.0.3 and Simpleportal 2.3.5

Offline Chas

  • Jr. Member
  • **
  • Posts: 74
  • Gender: Male
    • Fifty Plus Forum
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Re: Recent Image Attachments
« Reply #21 on: January 06, 2013, 01:44:55 AM »
I am not quite certain why this failed, and have not had time to test.
Have you looked at the HTML for that page to see where it has gone wrong?

Perhaps it would be best to abandon that supplied subroutine, and go back to the general idea
Code: (find in portalblocks.php) [Select]
$item['file']['image']['link']
Code: (replace in portalblocks.php) [Select]
'<a href="',  $item['topic']['href'],  '"><img src="', $item['file']['image']['thumb'],  '"></a>'

It seems to me this should still work, even if there are errors in the subroutine I supplied.

My apologies for supplying bad code.
This removes the images from the block and replaces them with links to the topic, is that what you intended?

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Recent Image Attachments
« Reply #22 on: January 07, 2013, 04:46:16 PM »
$item['file']['image']['thumb'] is the image that is shown.
Indeed, the link is to the topic.

That was the request from the OP -- to show the image, but link to the topic.

What would you like to show, and link to?
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline Chas

  • Jr. Member
  • **
  • Posts: 74
  • Gender: Male
    • Fifty Plus Forum
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Re: Recent Image Attachments
« Reply #23 on: January 07, 2013, 04:49:51 PM »
$item['file']['image']['thumb'] is the image that is shown.
Indeed, the link is to the topic.

That was the request from the OP -- to show the image, but link to the topic.

What would you like to show, and link to?
As the purpose of the module is to show the image I would like it to remain so but the image to be linked to the topic.
Thanks.

Offline velorooms

  • Jr. Member
  • **
  • Posts: 83
    • Velorooms
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: Recent Image Attachments
« Reply #24 on: January 07, 2013, 05:19:14 PM »
I posted my code two posts up. If look on my portal and click the recent images pictures (left hand side down a bit), they do exactly that, take you to the post in question.

And im using the code i posted. (unless there is more code i have changed somewhere else :S)
Admin and Owner of Velorooms.com - Using SMF 2.0.3 and Simpleportal 2.3.5

Offline Chas

  • Jr. Member
  • **
  • Posts: 74
  • Gender: Male
    • Fifty Plus Forum
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Re: Recent Image Attachments
« Reply #25 on: January 07, 2013, 05:23:37 PM »
Thanks Velorooms, I had tried your code and just got white pages.

Any chance you can post your portalblocks.php file so I can do a side by side comparison? Or even just use yours?

Thanks.

Offline velorooms

  • Jr. Member
  • **
  • Posts: 83
    • Velorooms
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: Recent Image Attachments
« Reply #26 on: January 07, 2013, 06:07:38 PM »
mine are attached for both 2.3.4 and 2.3.5

worth noting i have made some other adjustments to portal blocks to change a  few things. If you need to view differences try using examdiff which is a really good text file comparer.

I am wondering if i made a change somewhere other than in portalblocks.php I know it took me a while to figure it out. I really need to keep records. :S

DONT use my php file though. its heavily modified, for instance i have png post icons rather than gifs, theres a fair few non standard bits in there. Will mess things up. Ive isolated the line in the post below.
« Last Edit: January 07, 2013, 06:22:23 PM by velorooms »
Admin and Owner of Velorooms.com - Using SMF 2.0.3 and Simpleportal 2.3.5

Offline velorooms

  • Jr. Member
  • **
  • Posts: 83
    • Velorooms
  • SMF Version: 2.0.2
  • SP Version: 2.3.5
Re: Recent Image Attachments
« Reply #27 on: January 07, 2013, 06:15:12 PM »
Just looking through myself.

2.3.5 Portalblocks.php has this line

Code: [Select]
<a href="' . $item['file']['href'] . '">' . $item['file']['filename'] . '</a><br />' : ''), '
', $item['file']['image']['link'], '<br />', ($showDownloads ? '


I have

Code: [Select]
<a href="' . $item['file']['href'] . '">' . $item['file']['filename'] . '</a><br />' : ''), '
<a href="' . $item['topic']['href'] . '">', $item['file']['image']['thumb'], '</a> <br />', ($showDownloads ? '

what i appear to have done is surround the image thumb with a href linking to the topic

<a href="' . $item['topic']['href'] . '" 

Before the second line of code

and </a>  before the <br>

basically surrounded the thumbnail by a href.. i just need to work out if i specified 'topic' elsewhere in the file.
« Last Edit: January 07, 2013, 06:23:53 PM by velorooms »
Admin and Owner of Velorooms.com - Using SMF 2.0.3 and Simpleportal 2.3.5

Offline Chas

  • Jr. Member
  • **
  • Posts: 74
  • Gender: Male
    • Fifty Plus Forum
  • SMF Version: 2 RC5
  • SP Version: 2.3.3
Re: Recent Image Attachments
« Reply #28 on: January 08, 2013, 01:13:31 AM »
Just looking through myself.

2.3.5 Portalblocks.php has this line

Code: [Select]
<a href="' . $item['file']['href'] . '">' . $item['file']['filename'] . '</a><br />' : ''), '
', $item['file']['image']['link'], '<br />', ($showDownloads ? '


I have

Code: [Select]
<a href="' . $item['file']['href'] . '">' . $item['file']['filename'] . '</a><br />' : ''), '
<a href="' . $item['topic']['href'] . '">', $item['file']['image']['thumb'], '</a> <br />', ($showDownloads ? '

what i appear to have done is surround the image thumb with a href linking to the topic

<a href="' . $item['topic']['href'] . '" 

Before the second line of code

and </a>  before the <br>

basically surrounded the thumbnail by a href.. i just need to work out if i specified 'topic' elsewhere in the file.
Yes, that did the trick and was all that was needed to make the images in the block linked to the topic, exactly what I needed. many thanks.
Regards
Chas.

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Recent Image Attachments
« Reply #29 on: January 14, 2013, 08:20:22 PM »
Congratulations, you two! Chas, I'm glad you got it exactly the way you wanted it.
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?