Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 05-19-2014, 07:00 AM
pjkcards pjkcards is offline
 
Join Date: Jul 2007
Posts: 299
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default [solved] Automatic removal of [img] and [youtube] tags when quoting posts

Often, people quote posts that contain an embedded video or a large image, and when it's done excessively it takes up a lot of unnecessary vertical space (more scrolling) and can cause the threads to take longer to load.

Can images and videos using [img], [youtube], [youtubehd], [video] and other such tags be changed to just the URL of the image or video when using "Reply With Quote"? How can I go about this?

Thanks.
Reply With Quote
  #2  
Old 07-23-2014, 08:15 AM
pjkcards pjkcards is offline
 
Join Date: Jul 2007
Posts: 299
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

bump. Any help would be much appreciated.
Reply With Quote
  #3  
Old 07-23-2014, 08:41 AM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

<a href="https://vborg.vbsupport.ru/showthread.php?t=260337" target="_blank">https://vborg.vbsupport.ru/showthread.php?t=260337</a>

Is that what you're looking for?
Reply With Quote
  #4  
Old 07-24-2014, 04:55 AM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

While this isn't exactly what you asked for, what I did was edit the strip_quotes function in the file /includes/functions.php, with an array of tags literally defined to simply be removed, along with their contents:

PHP Code:
// #############################################################################
/**
* Strips away a defined set of tags and their contents from the specified string
*
* @param    string    Text to be stripped of tags
*
* @return    string
*/
function strip_quotes($text)
{
    
$tags = array('quote','desmos','graph','img','video','vimeo','youtube');
    
$i 0;

    while (isset(
$tags[$i]))
    {
        
$lowertext strtolower($text);
        
$stack = array();
        
$start_pos = array();
        
$end_pos = array();
        
$quit false;
        
$tag $tags[$i];
        
$taglength strlen($tag);
        
$newtext $text;

        
// find all opening tags

        
$curpos 0;
        do
        {
            
$pos strpos($lowertext'[' $tag$curpos);
            if (
$pos !== false AND ($lowertext[$pos $taglength 1] == '=' OR $lowertext[$pos $taglength 1] == ']'))
            {
                
$start_pos["$pos"] = 'start';
            }

            
$curpos $pos $taglength 1;
        }
        while (
$pos !== false);

        if (
count($start_pos) == 0)
        {
            
$quit true;
        }

        if (
$quit == false)
        {

            
// find all closing $tag tags
            
$curpos 0;
            do
            {
                
$pos strpos($lowertext'[/' $tag ']'$curpos);
                if (
$pos !== false)
                {
                    
$end_pos["$pos"] = 'end';
                    
$curpos $pos $taglength 3;
                }
            }
            while (
$pos !== false);

            if (
count($end_pos) == 0)
            {
                
$quit true;
            }

            if (
$quit == false)
            {

                
// merge them together and sort based on position in string
                
$pos_list $start_pos $end_pos;
                
ksort($pos_list);

                do
                {
                    
// build a stack that represents when a tag is opened
                    // and add non-tag text to the new string
                    
$newtext '';
                    
$substr_pos 0;
                    foreach (
$pos_list AS $pos => $type)
                    {
                        
$stacksize count($stack);
                        if (
$type == 'start')
                        {
                            
// empty stack, so add from the last close tag or the beginning of the string
                            
if ($stacksize == 0)
                            {
                                
$newtext .= substr($text$substr_pos$pos $substr_pos);
                            }
                            
array_push($stack$pos);
                        }
                        else
                        {
                            
// pop off the latest opened tag
                            
if ($stacksize)
                            {
                                
array_pop($stack);
                                
$substr_pos $pos $taglength 3;
                            }
                        }
                    }

                    
// add any trailing text
                    
$newtext .= substr($text$substr_pos);

                    
// check to see if there's a stack remaining, remove those points
                    // as key points, and repeat. Allows emulation of a non-greedy-type
                    // recursion.
                    
if ($stack)
                    {
                        foreach (
$stack AS $pos)
                        {
                            unset(
$pos_list["$pos"]);
                        }
                    }
                }
                while (
$stack);
                
$text $newtext;
            }
        }
        
$i++;
    }
    return 
$newtext;

Reply With Quote
  #5  
Old 08-16-2014, 03:35 AM
pjkcards pjkcards is offline
 
Join Date: Jul 2007
Posts: 299
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks guys. Dave's link seemed to work.

MarkFL: does your suggestion do anything different?
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:03 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07815 seconds
  • Memory Usage 2,244KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete