Blame view

common/behaviors/ShowImage.php 654 Bytes
9217ef8e   Administrator   09.02.16
1
2
3
4
5
6
7
8
9
10
  <?php
  
  namespace common\behaviors;
  
  use yii;
  use yii\base\Behavior;
  
  class ShowImage extends Behavior
  {
      function minImg($dir, $width, $height=null){
1aca8918   Administrator   09.02.16
11
12
13
14
          if(empty($dir)){
              return $dir;
          }
  
9217ef8e   Administrator   09.02.16
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
          if($width=='original'){
              $preg = '/\/(.[^\/]*)$/';
              preg_match('/\.(.[^.]*)$/', $dir, $type);
              $row = preg_replace( $preg, '/original.'.$type[1],  $dir);
          } else {
              $preg = '/\/(.[^\/]*)$/';
              preg_match('/\.(.[^.]*)$/', $dir, $type);
              $row =  preg_replace( $preg, '/'.$width.'X'.$height.'.'.$type[1],  $dir);
          }
          
          return $row;
  
  
      }
  
  }