Attached images do not appear in quotes. Workaround?

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Anti-Spam Guide
nonhocapito
Registered User
Posts: 2
Joined: Mon Apr 22, 2013 2:57 pm

Attached images do not appear in quotes. Workaround?

Post by nonhocapito » Mon Apr 22, 2013 3:40 pm

I understand not wanting to repeat redundant information... But imagine this:

A user quotes a post to comment on an image, but the image had been "attached", so in the quote it will appear just with the name of the file.

This is all fine and dandy if the original post is in the same page but what if the post is 20 or 30 pages earlier? Who's gonna know of which image we are talking about?

I think this is a serious limitation! At least in forums that have long threads and lots of images!
Is there a mod that works around this?

I would love it if attachment tags were parsed when quoted, although I imagine this would require some major rewriting (since the image is not attached to the post that's only quoting an earlier post); but maybe there is an alternative way to attach and embed that works around this? Any ideas?

User avatar
Mick
Support Team Member
Support Team Member
Posts: 21736
Joined: Fri Aug 29, 2008 9:49 am
Location: Cardiff

Re: Attached images do not appear in quotes. Workaround?

Post by Mick » Mon Apr 22, 2013 4:39 pm

If you right click the image and select Copy image location then insert that between [img] tags it will show in the new post.
"The more connected we get the more alone we become" - Kyle Broflovski

nonhocapito
Registered User
Posts: 2
Joined: Mon Apr 22, 2013 2:57 pm

Re: Attached images do not appear in quotes. Workaround?

Post by nonhocapito » Mon Apr 22, 2013 5:02 pm

Thanks this is a neat workaround. However it is bound to make newbies mad. They will just not understand why when they quote a picture it does not show up.

Could there exist a mod that makes this automagically? Taking a quoted attachment and turn it into the direct path to the picture?

dan filipi
Registered User
Posts: 82
Joined: Fri Dec 21, 2007 6:36 pm

Re: Attached images do not appear in quotes. Workaround?

Post by dan filipi » Wed Jul 03, 2013 12:31 pm

Mods, please delete this post.
Thanks.
Last edited by dan filipi on Wed Jul 03, 2013 11:07 pm, edited 1 time in total.

dan filipi
Registered User
Posts: 82
Joined: Fri Dec 21, 2007 6:36 pm

Re: Attached images do not appear in quotes. Workaround?

Post by dan filipi » Wed Jul 03, 2013 1:18 pm

The following edits make it so attached images will show in the quote.
Mind you my board is heavily modded so your code may be different.
As always, keep a backup of your original file and restore it if you have any problems.

Thanks out to Luc ( a member of my forum) for making this possible!

posting.php
Find:

Code: Select all

define('IN_PHPBB', true);
Add before:

Code: Select all

//Edit by Luc to support the quoting of attachments

Function isImage($filename) {
	$ext = strtolower(substr($filename, strrpos($filename, ".") + 1));
	switch($ext) {
		case "jpg":
		case "jpeg":
		case "gif":
		case "png":
		case "tga":
		case "tif":
		case "tiff":
		return true;
		break;
		
		default:
		return false;
		break;
	}
}

function getPageURL() {
	$pageURL = 'http';
	if ($_SERVER["HTTPS"] == "on") {
		$pageURL .= "s";
	}
	$pageURL .= "://";
	if ($_SERVER["SERVER_PORT"] != "80") {
		$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
	} else {
		$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
	}
	$pageURL = substr($pageURL, 0, strrpos($pageURL, "posting.php"));
	return $pageURL;
}

//End of Edit
Find:

Code: Select all

		$sql = 'SELECT f.*, t.*, p.*, u.username, u.username_clean, u.user_sig, u.user_sig_bbcode_uid, u.user_sig_bbcode_bitfield
		FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f, ' . USERS_TABLE . " u
		WHERE p.post_id = $post_id
			AND t.topic_id = p.topic_id
			AND u.user_id = p.poster_id
			AND (f.forum_id = t.forum_id
				OR f.forum_id = $forum_id)" .
			(($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND p.post_approved = 1');
Replace with:

Code: Select all

		//Edit by Luc to support quoting attachments
		$sql = 'SELECT a.real_filename, IFNULL(a.attach_id, 0) AS attach_id, p.post_id, f.forum_id, f.*, t.*, p.*, u.username, u.username_clean, u.user_sig, u.user_sig_bbcode_uid, u.user_sig_bbcode_bitfield
			FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f, ' . USERS_TABLE . ' u, ' . POSTS_TABLE . ' p
			LEFT JOIN ' . ATTACHMENTS_TABLE . " a ON a.post_msg_id = p.post_id
			WHERE p.post_id = $post_id
				AND t.topic_id = p.topic_id
				AND u.user_id = p.poster_id
				AND (f.forum_id = t.forum_id
					OR f.forum_id = $forum_id)" .
				(($auth->acl_get('m_approve', $forum_id)) ? '' : ' AND p.post_approved = 1');
		
		//$sql = 'SELECT f.*, t.*, p.*, u.username, u.username_clean, u.user_sig, u.user_sig_bbcode_uid, u.user_sig_bbcode_bitfield
		//	FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . ' f, ' . USERS_TABLE . " u
		//	WHERE p.post_id = $post_id
		//		AND t.topic_id = p.topic_id
		//		AND u.user_id = p.poster_id
		//		AND (f.forum_id = t.forum_id
		//			OR f.forum_id = $forum_id)" .
		//		(($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND p.post_approved = 1');
		//End of Edit
Find:

Code: Select all

$message_parser->message = '[quote="' . $post_data['quote_username'] . '"]' . censor_text(trim($message_parser->message)) . "[/quote]\n";
Replace with:

Code: Select all

		//Edit by Luc to support quoting attachments
		if ($post_data['attach_id'])
		{
			if(isImage($post_data['real_filename'])){
				$message_parser->message = '[quote="' . $post_data['quote_username'] . '"]' . censor_text(trim($message_parser->message)) . "\n[img]". getPageURL() . "download/file.$phpEx?id=" . $post_data['attach_id'] . "[/img][/quote]\n";
			} else {
				$message_parser->message = '[quote="' . $post_data['quote_username'] . '"]' . censor_text(trim($message_parser->message)) . "\n[url=". getPageURL() . "download/file.$phpEx?id=" . $post_data['attach_id'] . "]" . $post_data['real_filename'] . "[/url][/quote]\n";
			}
		}
		else
		{
			$message_parser->message = '[quote="' . $post_data['quote_username'] . '"]' . censor_text(trim($message_parser->message)) . "[/quote]\n";
		}
		//End of Edit
includes/functions_posting.php

Find:

Code: Select all

			$decoded_message = $message;
			decode_message($decoded_message, $row['bbcode_uid']);
Add after:

Code: Select all

			//Edit by Luc for attachment quoting
			if (!empty($attachments[$row['post_id']]))
			{
				foreach ($attachments[$row['post_id']] as $attachment)
				{
					if(isImage($attachment["real_filename"])){
						$decoded_message .= "\n[img]" . getPageURL() . "download/file.

$phpEx?id=" . $attachment['attach_id'] . "[/img]";
					}
					else {
						$decoded_message .= "\n[url=" . getPageURL() . "download/file.

$phpEx?id=" . $attachment['attach_id'] . "]" . $attachment["real_filename"] . "[/url]";
					}
				}
			}
			//End of Edit

God knows
Registered User
Posts: 15
Joined: Sun Aug 18, 2013 7:39 am

Re: Attached images do not appear in quotes. Workaround?

Post by God knows » Mon Aug 19, 2013 3:00 pm

Hello dan filipi!

I tried to use your modification for quotes in my forum!

it appears that if you quote a post with more than one image, only the first image appears in the quoted content.

Would you please correct it!

This especially occurs for inline images from attachments!

dan filipi
Registered User
Posts: 82
Joined: Fri Dec 21, 2007 6:36 pm

Re: Attached images do not appear in quotes. Workaround?

Post by dan filipi » Fri Aug 30, 2013 12:11 am

Sorry it took so long to get back.

Ok so Luc made an edit but it looks like the best we can come up with is including the images at the end of the quote. At least this way they ARE in the quoted text.

In root/posting.php find:

Code: Select all

      //Edit by Luc Breault to support quoting attachments
      if ($post_data['attach_id'])
      {
         if(isImage($post_data['real_filename'])){
            $message_parser->message = '[quote="' . '[url=' . generate_board_url() . "/viewtopic.$phpEx?p=$post_id#p$post_id" . ']' . $post_data['quote_username'] . ' » ' . $user->format_date($post_data['post_time']) . '[/url]' . '"]' . censor_text(trim($message_parser->message)) . "\n[img]". getPageURL() . "download/file.$phpEx?id=" . $attachments['attach_id'] . "[/img][/quote]\n";
         } else {
            $message_parser->message = '[quote="' . '[url=' . generate_board_url() . "/viewtopic.$phpEx?p=$post_id#p$post_id" . ']' . $post_data['quote_username'] . ' » ' . $user->format_date($post_data['post_time']) . '[/url]' . '"]' . censor_text(trim($message_parser->message)) . "\n[url=". getPageURL() . "download/file.$phpEx?id=" . $attachments['attach_id'] . "]" . $attachments['real_filename'] . "[/url][/quote]\n";
         }
      }
      else
      {
         $message_parser->message = '[quote="' . '[url=' . generate_board_url() . "/viewtopic.$phpEx?p=$post_id#p$post_id" . ']' . $post_data['quote_username'] . ' » ' . $user->format_date($post_data['post_time']) . '[/url]' . '"]' . censor_text(trim($message_parser->message)) . "[/quote]\n";
      }
      //End of Edit
Replace with:

Code: Select all

        //Edit by Luc Breault to support quoting attachments
		if ($post_data['attach_id'])
		{
			$select = "SELECT a.real_filename, IFNULL(a.attach_id, 0) AS attach_id FROM " . ATTACHMENTS_TABLE . " a WHERE a.post_msg_id = $post_id";
			$result = $db->sql_query($select);
			$quotes = "";
			while($attachments = $db->sql_fetchrow($result)){
				if(isImage($attachments['real_filename'])){
					$quotes = $quotes . "[img]". getPageURL() . "download/file.$phpEx?id=" . $attachments['attach_id'] . "[/img]\n";
					//$message_parser->message = '[quote="' . '[url=' . generate_board_url() . "/viewtopic.$phpEx?p=$post_id#p$post_id" . ']' . $post_data['quote_username'] . ' » ' . $user->format_date($post_data['post_time']) . '[/url]' . '"]' . censor_text(trim($message_parser->message)) . "\n[img]". getPageURL() . "download/file.$phpEx?id=" . $attachments['attach_id'] . "[/img][/quote]\n";
				} else {
					$quotes = $quotes . "[url=". getPageURL() . "download/file.$phpEx?id=" . $attachments['attach_id'] . "]" . $attachments['real_filename'] . "[/url]\n";
					//$message_parser->message = '[quote="' . '[url=' . generate_board_url() . "/viewtopic.$phpEx?p=$post_id#p$post_id" . ']' . $post_data['quote_username'] . ' » ' . $user->format_date($post_data['post_time']) . '[/url]' . '"]' . censor_text(trim($message_parser->message)) . "\n[url=". getPageURL() . "download/file.$phpEx?id=" . $attachments['attach_id'] . "]" . $attachments['real_filename'] . "[/url][/quote]\n";
				}
			}
			$message_parser->message = '[quote="' . '[url=' . generate_board_url() . "/viewtopic.$phpEx?p=$post_id#p$post_id" . ']' . $post_data['quote_username'] . ' » ' . $user->format_date($post_data['post_time']) . '[/url]' . '"]' . censor_text(trim($message_parser->message)) . "\n" . $quotes . "[/quote]\n";
			$db->sql_freeresult($result);
		}
		else
		{
			$message_parser->message = '[quote="' . '[url=' . generate_board_url() . "/viewtopic.$phpEx?p=$post_id#p$post_id" . ']' . $post_data['quote_username'] . ' » ' . $user->format_date($post_data['post_time']) . '[/url]' . '"]' . censor_text(trim($message_parser->message)) . "[/quote]\n";
		}
		//End of Edit

God knows
Registered User
Posts: 15
Joined: Sun Aug 18, 2013 7:39 am

Re: Attached images do not appear in quotes. Workaround?

Post by God knows » Sun Sep 01, 2013 5:55 am

Thanks for reply. Let me test this and I will come back to you later!

God knows
Registered User
Posts: 15
Joined: Sun Aug 18, 2013 7:39 am

Re: Attached images do not appear in quotes. Workaround?

Post by God knows » Sat Jan 11, 2014 5:21 pm

@dan filipi

Thank you and Luc for your efforts in making all those edits.

I like this feature as it appears in vBulletin Boards. The quoted images appear exactly where they were placed in the original topic/post.

I request you or any other member to work on it. It would atleast be nice!

Sorry: My knowledge about php is very little to accomplish this task

User avatar
ViolaF
Registered User
Posts: 1459
Joined: Tue Aug 14, 2012 11:52 pm

Re: Attached images do not appear in quotes. Workaround?

Post by ViolaF » Sat Jan 11, 2014 7:18 pm

God knows wrote:I request you or any other member to work on it. It would atleast be nice!
Why? Does it dont work anymore?

dan filipi
Registered User
Posts: 82
Joined: Fri Dec 21, 2007 6:36 pm

Re: Attached images do not appear in quotes. Workaround?

Post by dan filipi » Sat Jan 11, 2014 7:26 pm

Has been working fine for me on 3.0.12

User avatar
ViolaF
Registered User
Posts: 1459
Joined: Tue Aug 14, 2012 11:52 pm

Re: Attached images do not appear in quotes. Workaround?

Post by ViolaF » Sat Jan 11, 2014 7:27 pm

strike :D

God knows
Registered User
Posts: 15
Joined: Sun Aug 18, 2013 7:39 am

Re: Attached images do not appear in quotes. Workaround?

Post by God knows » Sat Jan 11, 2014 10:04 pm

My question is this:

If I have 3 images from attachment and they are placed inline with text, such as this:

text content
image1
text content
image2
text content
image3

When the above text is quoted, it will appear as follows:
text content
text content
text content
image1
image2
image3

I dont like this behaviour. I want the images to appear in the exact places as they were in the original post! That's what I am asking for................

User avatar
ViolaF
Registered User
Posts: 1459
Joined: Tue Aug 14, 2012 11:52 pm

Re: Attached images do not appear in quotes. Workaround?

Post by ViolaF » Sat Jan 11, 2014 11:07 pm

just a question of ordering, seems no big deal. in fact it works, so thats cosmetic ;)

God knows
Registered User
Posts: 15
Joined: Sun Aug 18, 2013 7:39 am

Re: Attached images do not appear in quotes. Workaround?

Post by God knows » Sun Jan 12, 2014 6:04 am

ViolaF wrote:just a question of ordering, seems no big deal. in fact it works, so thats cosmetic ;)
Hey you! Order is very important as anything else in these forums. What if for example, phpbb decided to mix up all these posts so that it is not known who is replying who, would you be able to read the posts and understand???????????????

Locked

Return to “[3.0.x] MOD Requests”