Jump to content


[Hack - IPB 2.1.x] Show image attachments in Board News block


5 replies to this topic

#1 visiblesoul

  • Administrators
  • 551 posts
  • Location:Earth
  • Texas

Posted 14 May 2006 - 06:56 PM

[Hack - IPB 2.1.x] Show image attachments in Board News block
Compatible with: M1.1 x IPB 2.1.x
Author: visiblesoul
Download: N/A
Demo: N/A
Description:

This little hack will allow IPB 2.1.x users to display image thumbnail attachments in the Board News block. The thumbnail size is determined by the max size that is set in the forum CP.

You will need to use the "Add into Post" attachment feature ( example: [attachment=1:attachment] ) for this to work.

Attached images will be centered in the block.

FIND in /mkportal/include/IPB/ipb_board_functions.php (function get_board_news):
		$DB->query("SELECT t.*, p.*, p.icon_id as icona, f.name as forum_name, m.id as member_id, m.name as member_name, a.avatar_location, a.avatar_size, a.avatar_type
		FROM ibf_posts p
REPLACE WITH:
/*
		$DB->query("SELECT t.*, p.*, p.icon_id as icona, f.name as forum_name, m.id as member_id, m.name as member_name, a.avatar_location, a.avatar_size, a.avatar_type
		FROM ibf_posts p
*/

		// Show attachments
		$DB->query("SELECT t.*, p.*, p.icon_id as icona, f.name as forum_name, m.id as member_id, m.name as member_name, a.avatar_location, a.avatar_size, a.avatar_type, at.attach_id, at.attach_thumb_location, at.attach_thumb_width, at.attach_thumb_height, at.attach_is_image, at.attach_pid, at.attach_approved
		FROM ibf_attachments at, ibf_posts p
FIND:
$testo = str_replace("style_emoticons/<#EMO_DIR#>", "$mkportals->forum_url/style_emoticons/default", $testo);
ADD AFTER:
		// Show attachments		
		if ( $post['topic_hasattach'] && $post['attach_is_image'] && $post['attach_approved'] ) {

			if ( $post['attach_thumb_location'] AND $post['attach_thumb_width'] ) {

				if ( strstr( $testo, '[attachmentid='.$post['attach_id'].']' ) ) {

					$testo = str_replace( '[attachmentid='.$post['attach_id'].']', "<div style="text-align:center"><img src="$mklib->siteurl/$mklib->forumpath/uploads/{$post['attach_thumb_location']}" height="{$post['attach_thumb_height']}" width="{$post['attach_thumb_width']}" border="0" alt="" /></div>", $testo );

				}
			}
		}
		// end Show Attachments



Please note that I offer free support on this forum in my free time. Depending on how much work I have backlogged it may take me a week or more to answer questions. I am not ignoring you. I answer everyone but please be patient. Thanks.

Disclaimer: All forum posts, including code examples, on this forum are offered for free in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Use code examples at your own risk.

"If at first you don't succeed, keep on suckin' til you do succeed." -Curly Howard

#2 A_T_b

  • Members
  • 2 posts

Posted 21 December 2007 - 11:23 AM

any chance 2 upgrade it 2 work with ipb 2.3

#3 visiblesoul

  • Administrators
  • 551 posts
  • Location:Earth
  • Texas

Posted 24 December 2007 - 08:17 AM

A_T_b said:

any chance 2 upgrade it 2 work with ipb 2.3
Welcome A_T_b.

I will try to upgrade this after the release of C1.2. If I forget please remind me.

-=DKC=-


Please note that I offer free support on this forum in my free time. Depending on how much work I have backlogged it may take me a week or more to answer questions. I am not ignoring you. I answer everyone but please be patient. Thanks.

Disclaimer: All forum posts, including code examples, on this forum are offered for free in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Use code examples at your own risk.

"If at first you don't succeed, keep on suckin' til you do succeed." -Curly Howard

#4 visiblesoul

  • Administrators
  • 551 posts
  • Location:Earth
  • Texas

Posted 28 December 2007 - 12:51 PM

A_T_b said:

any chance 2 upgrade it 2 work with ipb 2.3
This seems to be working. It needs improvement but its the best I can do until I have some free time, which will not be soon...

FIND in mkportal/include/IPB/ipb_board_functions:
		$DB->query("SELECT t.*, p.*, p.icon_id as icona, f.name as forum_name, m.id as member_id, m.members_display_name as member_name, a.avatar_location, a.avatar_size, a.avatar_type
		FROM ibf_posts p
		LEFT JOIN ibf_topics t on (t.tid=p.topic_id and t.topic_firstpost=p.pid and t.approved=1 and t.moved_to IS NULL)
		LEFT JOIN ibf_members m on (p.author_id=m.id)
		LEFT JOIN ibf_member_extra a on (p.author_id=a.id)
		LEFT JOIN ibf_forums f on (t.forum_id=f.id)
		WHERE t.forum_id IN (".implode(',', $forum_active ).")
		GROUP BY p.topic_id
		ORDER BY t.start_date DESC
		LIMIT $limit");
REPLACE WITH:
/*
		$DB->query("SELECT t.*, p.*, p.icon_id as icona, f.name as forum_name, m.id as member_id, m.members_display_name as member_name, a.avatar_location, a.avatar_size, a.avatar_type
		FROM ibf_posts p
		LEFT JOIN ibf_topics t on (t.tid=p.topic_id and t.topic_firstpost=p.pid and t.approved=1 and t.moved_to IS NULL)
		LEFT JOIN ibf_members m on (p.author_id=m.id)
		LEFT JOIN ibf_member_extra a on (p.author_id=a.id)
		LEFT JOIN ibf_forums f on (t.forum_id=f.id)
		WHERE t.forum_id IN (".implode(',', $forum_active ).")
		GROUP BY p.topic_id
		ORDER BY t.start_date DESC
		LIMIT $limit");
 */

		// Show attachments
		$DB->query("SELECT t.*, p.*, p.icon_id as icona, f.name as forum_name, m.id as member_id, m.members_display_name as member_name, a.avatar_location, a.avatar_size, a.avatar_type, at.attach_id, at.attach_file, at.attach_location, at.attach_thumb_location, at.attach_thumb_width, at.attach_thumb_height, at.attach_is_image, at.attach_pid, at.attach_approved, at.attach_post_key
		FROM ibf_posts p
		LEFT JOIN ibf_topics t on (t.tid=p.topic_id and t.topic_firstpost=p.pid and t.approved=1 and t.moved_to IS NULL)
		LEFT JOIN ibf_members m on (p.author_id=m.id)
		LEFT JOIN ibf_member_extra a on (p.author_id=a.id)
		LEFT JOIN ibf_forums f on (t.forum_id=f.id)
		LEFT JOIN ibf_attachments at on (p.post_key=at.attach_post_key)
		WHERE t.forum_id IN (".implode(',', $forum_active ).")
		GROUP BY p.topic_id
		ORDER BY t.start_date DESC
		LIMIT $limit");
FIND:
$testo = str_replace("style_emoticons/<#EMO_DIR#>", "style_emoticons/default", $testo); // IPB 2.2
ADD BELOW:
			// Show attachments		
			if ( $post['topic_hasattach'] && $post['attach_is_image'] && $post['attach_approved'] ) {

					if ( $post['attach_thumb_location'] AND $post['attach_thumb_width'] ) {

						if ( strstr( $testo, '[attachment='.$post['attach_id'].':'.$post['attach_file'].']') ) {

								$testo = str_replace( '[attachment='.$post['attach_id'].':'.$post['attach_file'].']', "<div style="text-align:center"><img src="$mklib->siteurl/$mklib->forumpath/uploads/{$post['attach_thumb_location']}" height="{$post['attach_thumb_height']}" width="{$post['attach_thumb_width']}" border="0" alt="" /></div>", $testo );

						}
			}
			else
			{
				if ( strstr( $testo, '[attachment='.$post['attach_id'].':'.$post['attach_file'].']') ) {

								$testo = str_replace( '[attachment='.$post['attach_id'].':'.$post['attach_file'].']', "<div style="text-align:center"><img src="$mklib->siteurl/$mklib->forumpath/uploads/{$post['attach_location']}" border="0" alt="" /></div>", $testo );
				
				}
			}

	   		 }
			// end Show Attachments
Note: this will not work correctly if some attachments in a post have thumbnails and others in the same post do not have thumbnails. This can be fixed but unfortunately I do not have time to work on this any more for awhile.


Please note that I offer free support on this forum in my free time. Depending on how much work I have backlogged it may take me a week or more to answer questions. I am not ignoring you. I answer everyone but please be patient. Thanks.

Disclaimer: All forum posts, including code examples, on this forum are offered for free in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Use code examples at your own risk.

"If at first you don't succeed, keep on suckin' til you do succeed." -Curly Howard

#5 A_T_b

  • Members
  • 2 posts

Posted 30 August 2008 - 09:46 PM

can u do tht fix now .....
thanks in advance

Edited by A_T_b, 31 August 2008 - 12:00 AM.


#6 visiblesoul

  • Administrators
  • 551 posts
  • Location:Earth
  • Texas

Posted 17 September 2008 - 10:29 AM

View PostA_T_b, on Aug 30 2008, 11:46 PM, said:

can u do tht fix now .....
thanks in advance

Hello A_T_b. Sorry for my delayed response. I do not know when I will have time to do any more work on this. It is not an easy fix so it will take me a long time. Unfortunately I have many things I must work on first. I have released so many free mods that it is impossible for me to keep them all updated myself. I will try to update this but I do not have any estimate of when I will have time to work on my free mods. Sorry.

-=DKC=-


Please note that I offer free support on this forum in my free time. Depending on how much work I have backlogged it may take me a week or more to answer questions. I am not ignoring you. I answer everyone but please be patient. Thanks.

Disclaimer: All forum posts, including code examples, on this forum are offered for free in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Use code examples at your own risk.

"If at first you don't succeed, keep on suckin' til you do succeed." -Curly Howard





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users