vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Png link auto embed(convert) (https://vborg.vbsupport.ru/showthread.php?t=324373)

mobster46 02-05-2017 08:04 AM

Png link auto embed(convert)
 
How can I automatically convert a picture when I add a link?

For example
http://travian-reports.net/tr/img/154441a5f4e.png

I do not want it to appear as a link.

I find auto youtube embed(https://vborg.vbsupport.ru/showthread.php?t=261296)
but ı dont find image link convert.

MarkFL 02-05-2017 08:42 AM

Create a plugin hooked at "postbit_display_start" with the code:

PHP Code:

$post['pagetext'] = preg_replace('/\[url\](http.*?\.png)\[\/url\]/''[img]https://vborg.vbsupport.ru/[/img]'$post['pagetext']); 


Stratis 02-08-2017 05:47 PM

Mark to include more, png, gif, jpeg, etc ?

Thanks in advanced :)

mobster46 02-10-2017 04:12 AM

Quote:

Originally Posted by MarkFL (Post 2581852)
Create a plugin hooked at "postbit_display_start" with the code:

PHP Code:

$post['pagetext'] = preg_replace('/\[url\](http.*?\.png)\[\/url\]/''[img]https://vborg.vbsupport.ru/[/img]'$post['pagetext']); 


Mark to include more, png, gif, jpeg, etc ?

Thanks in advanced

MarkFL 02-10-2017 04:36 AM

Quote:

Originally Posted by mobster46 (Post 2582134)
Mark to include more, png, gif, jpeg, etc ?

Thanks in advanced

You may recall I had to add some code because of post caching...please post the entire content of the plugin I put on your site, and I will modify it to include more file extensions. :)

mobster46 02-10-2017 07:31 AM

Quote:

Originally Posted by MarkFL (Post 2582136)
You may recall I had to add some code because of post caching...please post the entire content of the plugin I put on your site, and I will modify it to include more file extensions. :)

I do not know what you add: D

Stratis 02-13-2017 02:52 PM

Quote:

Originally Posted by mobster46 (Post 2582137)
I do not know what you add: D

admincp

Plugins & Products -> Plugin Manager -> You must remember the title to see it, maybe at top.
Read and i thing you will understand which is..

* If you press on the title you will see the code :)

mobster46 02-13-2017 04:34 PM

Quote:

Originally Posted by Stratis (Post 2582265)
admincp

Plugins & Products -> Plugin Manager -> You must remember the title to see it, maybe at top.
Read and i thing you will understand which is..

* If you press on the title you will see the code :)

There is not.

--------------- Added [DATE]1487010990[/DATE] at [TIME]1487010990[/TIME] ---------------

https://vborg.vbsupport.ru/external/2017/02/7.png

--------------- Added [DATE]1487011022[/DATE] at [TIME]1487011022[/TIME] ---------------

https://vborg.vbsupport.ru/external/2017/02/8.png

--------------- Added [DATE]1487011282[/DATE] at [TIME]1487011282[/TIME] ---------------

ok ı see. sory

true?

$content = preg_replace('/\[URL\](http.*?\.png)\[\/URL\]/i', 'https://vborg.vbsupport.ru/', $post['pagetext']);
$content = preg_replace('/\[URL\](http.*?\.jpg)\[\/URL\]/i', 'https://vborg.vbsupport.ru/', $post['pagetext']);

if ($content != $post['pagetext'])
{
global $vbulletin;
$pagetext = $content;
require_once(DIR . '/includes/class_bbcode.php');
$bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list());
$post['pagetext_html'] = $bbcode_parser->parse($pagetext, $post['forumid'], 1);
$post['pagetext_html'] = html_entity_decode($post['pagetext_html']);
}

BadgerDog 02-16-2017 03:46 PM

This looks interesting ..

So, for clarity, if I create a plugin titled with some name and hooked at "postbit_display_start" with the code:

Quote:

$content = preg_replace('/\[URL\](http.*?\.png)\[\/URL\]/i', 'https://vborg.vbsupport.ru/', $post['pagetext']);
$content = preg_replace('/\[URL\](http.*?\.jpg)\[\/URL\]/i', 'https://vborg.vbsupport.ru/', $post['pagetext']);

if ($content != $post['pagetext'])
{
global $vbulletin;
$pagetext = $content;
require_once(DIR . '/includes/class_bbcode.php');
$bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list());
$post['pagetext_html'] = $bbcode_parser->parse($pagetext, $post['forumid'], 1);
$post['pagetext_html'] = html_entity_decode($post['pagetext_html']);
}
Then the site will automatically display all links that were PNG and JPG as pictures?

Regards,
Doug

MarkFL 02-16-2017 04:12 PM

What you would want for the first line is:

PHP Code:

$content preg_replace('/\[URL\](http.*?\.(png|jpg|gif))\[\/URL\]/i''[img]https://vborg.vbsupport.ru/[/img]'$post['pagetext']); 


BadgerDog 02-16-2017 04:15 PM

Quote:

Originally Posted by MarkFL (Post 2582460)
What you would want for the first line is:

PHP Code:

$content preg_replace('/\[URL\](http.*?\.(png|jpg|gif))\[\/URL\]/i''[img]https://vborg.vbsupport.ru/[/img]'$post['pagetext']); 


Thank you Mark ... :)

You are always so gracious and helpful on this site... :up:

Regards,
Doug

Stratis 02-16-2017 05:14 PM

Quote:

Originally Posted by MarkFL (Post 2582460)
What you would want for the first line is:

PHP Code:

$content preg_replace('/\[URL\](http.*?\.(png|jpg|gif))\[\/URL\]/i''[img]https://vborg.vbsupport.ru/[/img]'$post['pagetext']); 


is this the final?

Code:

$content = preg_replace('/\[URL\](http.*?\.(png|jpg|gif))\[\/URL\]/i', 'https://vborg.vbsupport.ru/', $post['pagetext']);
if ($content != $post['pagetext'])
 {
 global $vbulletin;
 $pagetext = $content;
require_once(DIR . '/includes/class_bbcode.php');
 $bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list());
 $post['pagetext_html'] = $bbcode_parser->parse($pagetext, $post['forumid'], 1);
 $post['pagetext_html'] = html_entity_decode($post['pagetext_html']);
 }

because in post #2 you do not have all this code :)

Thank you very much

MarkFL 02-16-2017 05:21 PM

Quote:

Originally Posted by Stratis (Post 2582464)
is this the final?

Code:

$content = preg_replace('/\[URL\](http.*?\.(png|jpg|gif))\[\/URL\]/i', 'https://vborg.vbsupport.ru/', $post['pagetext']);
if ($content != $post['pagetext'])
 {
 global $vbulletin;
 $pagetext = $content;
require_once(DIR . '/includes/class_bbcode.php');
 $bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list());
 $post['pagetext_html'] = $bbcode_parser->parse($pagetext, $post['forumid'], 1);
 $post['pagetext_html'] = html_entity_decode($post['pagetext_html']);
 }

because in post #2 you do not have all this code :)

Thank you very much

Post #2 was what worked on my local dev site, but then I realized it worked for me because I have post caching turned off there...so, I revised the code to reparse the post for the OP, who has post caching turned on.

Stratis 02-16-2017 05:59 PM

Ok, I have "Cached Posts Lifespan" to zero (0)
so i will use the first line. Thanks Mark.

MarkFL 02-16-2017 06:12 PM

Quote:

Originally Posted by Stratis (Post 2582469)
Ok, I have "Cached Posts Lifespan" to zero (0)
so i will use the first line. Thanks Mark.

In that case, you would want:

PHP Code:

$post['pagetext'] = preg_replace('/\[URL\](http.*?\.(png|jpg|gif))\[\/URL\]/i''[img]https://vborg.vbsupport.ru/[/img]'$post['pagetext']); 

:)

Stratis 02-16-2017 06:19 PM

Yes, Yes :)

--------------- Added [DATE]1487278112[/DATE] at [TIME]1487278112[/TIME] ---------------

I forgot to ask, I want to recognize when link images turn to img, is there a way to put in code some title that I would like and to show at the bottom of the image?

or attribute to see when hover image :D

BadgerDog 02-21-2017 12:22 PM

Ok, for my clarity and so I don't screw it up ... :)

Is this the code I need to use to create the plugin discussed?

Quote:

$post['pagetext'] = preg_replace('/\[URL\](http.*?\.(png|jpg|gif))\[\/URL\]/i', 'https://vborg.vbsupport.ru/', $post['pagetext']);
if ($content != $post['pagetext'])
{
global $vbulletin;
$pagetext = $content;
require_once(DIR . '/includes/class_bbcode.php');
$bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list());
$post['pagetext_html'] = $bbcode_parser->parse($pagetext, $post['forumid'], 1);
$post['pagetext_html'] = html_entity_decode($post['pagetext_html']);
}
Thanks .. :)

Regards,
Doug

MarkFL 02-21-2017 12:52 PM

Quote:

Originally Posted by BadgerDog (Post 2582699)
Ok, for my clarity and so I don't screw it up ... :)

Is this the code I need to use to create the plugin discussed?



Thanks .. :)

Regards,
Doug

You want:

PHP Code:

$content preg_replace('/\[URL\](http.*?\.(png|jpg|gif))\[\/URL\]/i''[img]https://vborg.vbsupport.ru/[/img]'$post['pagetext']);

if (
$content != $post['pagetext'])
{
    global 
$vbulletin;
    
$pagetext $content;
    require_once(
DIR '/includes/class_bbcode.php');
    
$bbcode_parser = new vB_BbCodeParser($vbulletinfetch_tag_list());
    
$post['pagetext_html'] = $bbcode_parser->parse($pagetext$post['forumid'], 1);
    
$post['pagetext_html'] = html_entity_decode($post['pagetext_html']);



BadgerDog 02-21-2017 01:10 PM

Quote:

Originally Posted by MarkFL (Post 2582700)
You want:

PHP Code:

$content preg_replace('/\[URL\](http.*?\.(png|jpg|gif))\[\/URL\]/i''[IMG]$1[/IMG]'$post['pagetext']);

if (
$content != $post['pagetext'])
{
    global 
$vbulletin;
    
$pagetext $content;
    require_once(
DIR '/includes/class_bbcode.php');
    
$bbcode_parser = new vB_BbCodeParser($vbulletinfetch_tag_list());
    
$post['pagetext_html'] = $bbcode_parser->parse($pagetext$post['forumid'], 1);
    
$post['pagetext_html'] = html_entity_decode($post['pagetext_html']);



Thanks again .. :up:

Regards,
Doug


All times are GMT. The time now is 07:13 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01277 seconds
  • Memory Usage 1,819KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_code_printable
  • (8)bbcode_php_printable
  • (13)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (19)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete