Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product
Please upgrade here. These earlier versions are no longer being updated and have security issues.

Great addon but needs improvement.

This discussion is related to the IndexDiscussionImage addon.

This addon works on vanilla version 2.2. It makes forum look outstanding by addon discussion index pictures.
However, it slows down vanilla page load speed.
Can this addon be improved to solve the issues of:

  • Specify image dimensions
  • Serve scaled images
  • Optimize images
    These improvement were reported by gtmetrix.

Comments

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    The images are the ones that are posted in the discussion . The dimensions of an image has nothing to do with it's weight in resolution . Make sure the images posted in the discussions do not weigh too much. Your issues have absolutely nothing to do with this plugin because all this plugin does is call the image if any from the original discussion. It does not serve anything.

  • ProsperProsper ✭✭
    edited December 2015

    @vrijvlinder - Thanks for your explanation.
    Is there a way to make the index pictures clickable to open up discussion pages where the images are displayed?

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    You could make the css z-index for the images in the plugin to be bellow the link for the discussion that already takes up the entire space there in the index. I am guessing -1 but you would have to play with it.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited December 2015

    Ok, I played around with this and came up with this. Replace all the code from the original plugin with this and report if it works for you. If it does and you like it, I will update the plugin for everyone.

        class IndexDiscussionImagePlugin extends Gdn_Plugin {
       /**
        * Add style sheet.
        */
       public function DiscussionsController_Render_Before($Sender) {
          $Sender->AddCssFile($this->GetResource('design/idi.css', FALSE, FALSE));
       }
    
       // Trigger on All Discussions.
    
       public function DiscussionsController_BeforeDiscussionContent_Handler($Sender) {
    
    
            $CssItem = $Sender->EventArguments['CssClass'];
            $CssItem = str_replace("Bookmarked"," ",$CssItem);
            $bodyLine = $Sender->EventArguments['Discussion']->Body;    
            $formline = strip_tags(str_replace(array('[',']'), array('<','>'), $bodyLine));   
           $sline = substr($formline, 0, 220) . "..." ;
           $oldName = $Sender->EventArguments['Discussion']->Name;
           $oldUrl = $Sender->EventArguments['Discussion']->Url;
            $ImageSrc = '/applications/dashboard/design/images/pixel.png';
            preg_match('#\<img.+?src="([^"]*).+?\>#s', $Sender->EventArguments['Discussion']->Body, $images);
            if ($images[1]) {
                $ImageSrc = $images[1];
            }
    
            $newTitleAnchor  = '<a class="IndexImage" href="' . $Sender->EventArguments['Discussion']->Url  . '">' .  Img($ImageSrc,  array('title' => $sline, 'class' => "IndexImage")) . '</a>';
    
    
    
           echo "$newTitleAnchor";
    
    
       }
    
    }
    
  • @vrijvlinder - thank you for your latest update to the addon. It is awesome. However, I noticed that index discussion image is only trigger on recent discussion pages. Please can it be triggered on category pages also? Or settings option to trigger on category pages also?

  • vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited December 2015

    It can only be made to work in each category list..

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    Ok I made it show the images but only can do this in the selected category and not on the category index.

    Try the new version I uploaded and see if that works for you.

    Prosper
  • ProsperProsper ✭✭
    edited December 2015

    @vrijvlinder - Thank you. It works great.

    vrijvlinder
Sign In or Register to comment.