Users running a non-download version of Vanilla (pulled from github), on branch release/2019.016 or master from the last 2 weeks should upgrade to release/2019.017 or latest master for security reasons. Downloaded official open sources releases are not affected.

Resize discussion Images into smaller resolution

Is there a way to resize the discussion images into a thumbnail size (ex. 50x50) I am planning to display them in the discussion index page.

  public functionDiscussionsController_AfterDiscussionTitle_Handler($Sender){
  
       $body=json_decode($Sender->EventArguments['Discussion']->Body);

       foreach($bodyas$key=>$value){

         $key='embed-external';

         if($value->insert&&$value->insert->$key&&$value->insert->$key->data){
            
                $ImageSrc = $this->SOME_RESIZE_METHOD($value->insert->$key->data->url);
            
               $images.= '<aclass="someclass"href="'.$Sender->EventArguments['Discussion']->Url .'">'. Img($ImageSrc, array('class'=>"someclass")).'</a>';
         
         }
       }
       if($images){
         echo'<spanclass="someclass">'.$images.'</span>';
       }
  }
 

  public functionCategoriesController_AfterDiscussionTitle_Handler($Sender){

       $body=json_decode($Sender->EventArguments['Discussion']->Body);

       foreach($bodyas$key=>$value){

         $key='embed-external';

         if($value->insert&&$value->insert->$key&&$value->insert->$key->data){
     
            $ImageSrc = $this->SOME_RESIZE_METHOD($value->insert->$key->data->url);
         
               $images.= '<aclass="someclass"href="'.$Sender->EventArguments['Discussion']->Url .'">'. Img($ImageSrc, array('class'=>"someclass")).'</a>';
         
         }
       }

       if($images){
         echo'<spanclass="someclass">'.$images.'</span>';
       }
  }

Thanks

Comments

  • I assume there is a resize functionality that would resize the image and save it somewhere for later use..

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    Vanilla implements something like that, but it needs some time studying the class to use it. At least I always need time for it. Look at the methods in /library/core/class.uploadimage.php


Sign In or Register to comment.