Changeset 3968:075785b9d306
- Timestamp:
- 05/17/19 12:20:13 (6 years ago)
- Branch:
- default
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
.hgsubstate
r3938 r3968 1 c019de4d8ec41f12428c20bd19b2166548802c28inc/libs/clearbricks1 d0492625e961be1bd1b5138de54ef04d68cad199 inc/libs/clearbricks -
admin/media_item.php
r3959 r3968 702 702 } 703 703 704 if ($file->type == 'image/jpeg' ) {704 if ($file->type == 'image/jpeg' || $file->type == 'image/webp') { 705 705 echo '<h3>' . __('Image details') . '</h3>'; 706 706 -
inc/core/class.dc.media.php
r3958 r3968 25 25 protected $file_handler = []; ///< <b>array</b> Array of callbacks 26 26 27 public $thumb_tp = '%s/.%s_%s.jpg'; ///< <b>string</b> Thumbnail file pattern28 public $thumb_tp_alpha = '%s/.%s_%s.png'; ///< <b>string</b> Thumbnail file pattern (with alpha layer)29 27 public $thumb_tp = '%s/.%s_%s.jpg'; ///< <b>string</b> Thumbnail file pattern 28 public $thumb_tp_alpha = '%s/.%s_%s.png'; ///< <b>string</b> Thumbnail file pattern (with alpha layer) 29 public $thumb_tp_webp = '%s/.%s_%s.webp'; ///< <b>string</b> Thumbnail file pattern (webp) 30 30 /** 31 31 <b>array</b> Tubmnail sizes: … … 94 94 $this->addFileHandler('image/png', 'create', [$this, 'imageThumbCreate']); 95 95 $this->addFileHandler('image/gif', 'create', [$this, 'imageThumbCreate']); 96 $this->addFileHandler('image/webp', 'create', [$this, 'imageThumbCreate']); 96 97 97 98 $this->addFileHandler('image/png', 'update', [$this, 'imageThumbUpdate']); 98 99 $this->addFileHandler('image/jpeg', 'update', [$this, 'imageThumbUpdate']); 99 100 $this->addFileHandler('image/gif', 'update', [$this, 'imageThumbUpdate']); 101 $this->addFileHandler('image/webp', 'update', [$this, 'imageThumbUpdate']); 100 102 101 103 $this->addFileHandler('image/png', 'remove', [$this, 'imageThumbRemove']); 102 104 $this->addFileHandler('image/jpeg', 'remove', [$this, 'imageThumbRemove']); 103 105 $this->addFileHandler('image/gif', 'remove', [$this, 'imageThumbRemove']); 106 $this->addFileHandler('image/webp', 'remove', [$this, 'imageThumbRemove']); 104 107 105 108 $this->addFileHandler('image/jpeg', 'create', [$this, 'imageMetaCreate']); 109 $this->addFileHandler('image/webp', 'create', [$this, 'imageMetaCreate']); 106 110 107 111 $this->addFileHandler('image/jpeg', 'recreate', [$this, 'imageThumbCreate']); 108 112 $this->addFileHandler('image/png', 'recreate', [$this, 'imageThumbCreate']); 109 113 $this->addFileHandler('image/gif', 'recreate', [$this, 'imageThumbCreate']); 110 111 $this->addFileHandler('image/jpeg', 'recreate', [$this, 'imageThumbCreate']); 112 $this->addFileHandler('image/png', 'recreate', [$this, 'imageThumbCreate']); 113 $this->addFileHandler('image/gif', 'recreate', [$this, 'imageThumbCreate']); 114 $this->addFileHandler('image/webp', 'recreate', [$this, 'imageThumbCreate']); 114 115 115 116 # Thumbnails sizes … … 294 295 $p = path::info($f->relname); 295 296 296 $alpha = ($p['extension'] == 'png') || ($p['extension'] == 'PNG'); 297 298 $thumb = sprintf(($alpha ? $this->thumb_tp_alpha : $this->thumb_tp), $this->root . '/' . $p['dirname'], $p['base'], '%s'); 299 $thumb_url = sprintf(($alpha ? $this->thumb_tp_alpha : $this->thumb_tp), $this->root_url . $p['dirname'], $p['base'], '%s'); 297 $alpha = strtolower($p['extension']) === 'png'; 298 $webp = strtolower($p['extension']) === 'webp'; 299 300 $thumb = sprintf( 301 ($alpha ? $this->thumb_tp_alpha : 302 ($webp ? $this->thumb_tp_webp : $this->thumb_tp)), 303 $this->root . '/' . $p['dirname'], $p['base'], '%s'); 304 $thumb_url = sprintf( 305 ($alpha ? $this->thumb_tp_alpha : 306 ($webp ? $this->thumb_tp_webp : $this->thumb_tp)), 307 $this->root_url . $p['dirname'], $p['base'], '%s'); 300 308 301 309 # Cleaner URLs … … 303 311 $thumb_url = preg_replace('#(?<!:)/+#', '/', $thumb_url); 304 312 305 if ($alpha ) {313 if ($alpha || $webp) { 306 314 $thumb_alt = sprintf($this->thumb_tp, $this->root . '/' . $p['dirname'], $p['base'], '%s'); 307 315 $thumb_url_alt = sprintf($this->thumb_tp, $this->root_url . $p['dirname'], $p['base'], '%s'); … … 314 322 if (file_exists(sprintf($thumb, $suffix))) { 315 323 $f->media_thumb[$suffix] = sprintf($thumb_url, $suffix); 316 } elseif ( $alpha&& file_exists(sprintf($thumb_alt, $suffix))) {324 } elseif (($alpha || $webp) && file_exists(sprintf($thumb_alt, $suffix))) { 317 325 $f->media_thumb[$suffix] = sprintf($thumb_url_alt, $suffix); 318 326 } … … 913 921 $zip = new fileUnzip($f->file); 914 922 $zip->setExcludePattern($this->exclude_pattern); 915 $list = $zip->getList(false, '#(^|/)(__MACOSX|\.svn|\. DS_Store|\.directory|Thumbs\.db)(/|$)#');923 $list = $zip->getList(false, '#(^|/)(__MACOSX|\.svn|\.hg|\.git|\.DS_Store|\.directory|Thumbs\.db)(/|$)#'); 916 924 917 925 if ($create_dir) { … … 965 973 { 966 974 $zip = new fileUnzip($f->file); 967 $list = $zip->getList(false, '#(^|/)(__MACOSX|\.svn|\. DS_Store|\.directory|Thumbs\.db)(/|$)#');975 $list = $zip->getList(false, '#(^|/)(__MACOSX|\.svn|\.hg|\.git|\.DS_Store|\.directory|Thumbs\.db)(/|$)#'); 968 976 $zip->close(); 969 977 return $list; … … 992 1000 993 1001 $p = path::info($file); 994 $alpha = ($p['extension'] == 'png') || ($p['extension'] == 'PNG'); 995 $thumb = sprintf(($alpha ? $this->thumb_tp_alpha : $this->thumb_tp), $p['dirname'], $p['base'], '%s'); 1002 $alpha = strtolower($p['extension']) === 'png'; 1003 $webp = strtolower($p['extension']) === 'webp'; 1004 $thumb = sprintf(($alpha ? $this->thumb_tp_alpha : 1005 ($webp ? $this->thumb_tp_webp : 1006 $this->thumb_tp)), 1007 $p['dirname'], $p['base'], '%s'); 996 1008 997 1009 try … … 1013 1025 $rate = ($s[0] < 100 ? 95 : ($s[0] < 600 ? 90 : 85)); 1014 1026 $img->resize($s[0], $s[0], $s[1]); 1015 $img->output(($alpha ? 'png': 'jpeg'), $thumb_file, $rate);1027 $img->output(($alpha || $webp ? strtolower($p['extension']) : 'jpeg'), $thumb_file, $rate); 1016 1028 $img->loadImage($file); 1017 1029 } … … 1030 1042 if ($file->relname != $newFile->relname) { 1031 1043 $p = path::info($file->relname); 1032 $alpha = ($p['extension'] == 'png') || ($p['extension'] == 'PNG'); 1033 $thumb_old = sprintf(($alpha ? $this->thumb_tp_alpha : $this->thumb_tp), $p['dirname'], $p['base'], '%s'); 1044 $alpha = strtolower($p['extension']) === 'png'; 1045 $webp = strtolower($p['extension']) === 'webp'; 1046 $thumb_old = sprintf(($alpha ? $this->thumb_tp_alpha : 1047 ($webp ? $this->thumb_tp_webp : 1048 $this->thumb_tp)), 1049 $p['dirname'], $p['base'], '%s'); 1034 1050 1035 1051 $p = path::info($newFile->relname); 1036 $alpha = ($p['extension'] == 'png') || ($p['extension'] == 'PNG'); 1037 $thumb_new = sprintf(($alpha ? $this->thumb_tp_alpha : $this->thumb_tp), $p['dirname'], $p['base'], '%s'); 1052 $alpha = strtolower($p['extension']) === 'png'; 1053 $webp = strtolower($p['extension']) === 'webp'; 1054 $thumb_new = sprintf(($alpha ? $this->thumb_tp_alpha : 1055 ($webp ? $this->thumb_tp_webp : 1056 $this->thumb_tp)), 1057 $p['dirname'], $p['base'], '%s'); 1038 1058 1039 1059 foreach ($this->thumb_sizes as $suffix => $s) { … … 1048 1068 { 1049 1069 $p = path::info($f); 1050 $alpha = ($p['extension'] == 'png') || ($p['extension'] == 'PNG'); 1051 $thumb = sprintf(($alpha ? $this->thumb_tp_alpha : $this->thumb_tp), '', $p['base'], '%s'); 1070 $alpha = strtolower($p['extension']) === 'png'; 1071 $webp = strtolower($p['extension']) === 'webp'; 1072 $thumb = sprintf(($alpha ? $this->thumb_tp_alpha : 1073 ($webp ? $this->thumb_tp_webp : 1074 $this->thumb_tp)), 1075 '', $p['base'], '%s'); 1052 1076 1053 1077 foreach ($this->thumb_sizes as $suffix => $s) {
Note: See TracChangeset
for help on using the changeset viewer.