Jump to content

(tng31) Quoted Images as Links


alexp999

Recommended Posts

%7Boption%7D



File Name: (tng31) Quoted Images as Links

File Submitter: alexp999

File Submitted: 11 Sep 2011

File Category: Performance

Supported Versions: IP.Board 3.1.x



This is the IPB 3.1 version of this hook, for the 3.2 version, click here.

Displays quoted images as Lightbox enabled links to the original image. This saves space in your threads and means a post full of pictures is not repeated when someone quotes it.
Users can also click on the generated link and if they have javascript, a lightbox will open showing the original image.

This hook works by searching for quotes in a post, it will then strip away any BBCode images in those quotes (based on bbc_img class), replacing them with lightbox enabled urls to the original image, shortened and styled like standard BBCode urls.

This hook has been tested on an English board but has been written to hopefully work with any language and will use the alt text of the image, as the title(shown on hover) of the link. (e.g. Posted Image)


NOTE:
This hook was written for IPB 3.1.
This hook is only for forum topics
This hook only alters the DISPLAY of images quoted in posts, post data is not changed, the database remains untouched and as a result if a post is edited or quoted, the url to the quoted image will still be in %7Boption%7D tags



here to download this file

Link to comment
Share on other sites

  • 3 months later...

The IPB 3.1 version is bugged.

When you quote a smiley and a image, the smiley will destroy the REG expression of the image. So a wrong link will be made.
At this moment i do not have the fix.. Still working on that.

The system takes:

( [0] => <img src=' ' alt='Posted Image' class='bbc_img' /> [1] => [2] => Posted Image ) Array ( [0] => <img src='[link]/public/style_emoticons/<#EMO_DIR#>/ohmy.gif' class='bbc_emoticon' alt=':o' /><br /><br /><img src='http://www.rap-wallpapers.com/data/media/14/ban_50_cent_01.jpg' alt='Posted Image' class='bbc_img' /> [1] => [link]/public/style_emoticons/<#EMO_DIR#>/ohmy.gif' class='bbc_emoticon [2] => :o' /><br /><br /><img src='http://www.rap-wallpapers.com/data/media/14/ban_50_cent_01.jpg' alt='Posted Image )

Array




The main reason is that the IMG HTML code is

<img src='link' alt='alt' class='bbc_img' />

and the smiley is

<img src='link' class='bbc_emoticon' alt='alt' />

Link to comment
Share on other sites

Edit:

This will sort of 'solve' the problem. Only the smiley will be deleted.

only for IPB 3.1
Replace the private function _replaceImages with this:

private function _replaceImages($match2)			{				$link = $match2[1];				if ( (strpos( $link, 'bbc_emoticon' ) !== FALSE  ) ) {					$pattern3 = '/<img src='(.*?)' alt/i';					$newlink = preg_replace_callback($pattern3,array($this, '_newImages'),$match2[2]);										$newlink = explode ( '[', $newlink);					$newlink = explode ( ']', $newlink[1]);										$link = $newlink[0];					$match2[1] = $link;					$match2[2] = 'image';				}								if( ( empty( $this->settings['__noTruncateUrl'] ) ) AND IPSText::mbstrlen($link) > 38 )				{					$link = htmlspecialchars( IPSText::mbsubstr( html_entity_decode( $link ), 0, 20 ) ) . '...' . htmlspecialchars( IPSText::mbsubstr( html_entity_decode( $link ), -15 ) );				}				return '<a href="' . $match2[1] . '" class="bbc_url" title="' . $match2[2] . '" rel="lightbox" onclick="return false">' . $link . '</a>';			}						private function _newImages($match3)			{				$giveback = '[' . $match3[1] . ']';				return $giveback;			}



This is not the best fix. I couldn't get it with the reg expression

Oops, i thought the post are merged together here

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...