HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

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

  • Options

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

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    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.