Skip to content
This repository has been archived by the owner on Feb 23, 2021. It is now read-only.

Adding dimensions as an option for thumbnail and list view. #71

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cache/theme_dark.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cache/theme_default.css

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion core/class/browser.php
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,7 @@ protected function getFiles($dir) {
$bigIcon = file_exists("themes/{$this->config['theme']}/img/files/big/$ext.png");
$smallIcon = file_exists("themes/{$this->config['theme']}/img/files/small/$ext.png");
$thumb = file_exists("$thumbDir/$name");
list($width, $height) = $img->getSize();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Size is already extracted on line 717:

$size = $img->getSize($file);

There is no need to extract the size twice. This can be avoided by replacing your line 740 with:

if ($type && count($size) >= 2)
  list($width, $height) = $size;

$return[] = array(
'name' => stripcslashes($name),
'size' => $stat['size'],
Expand All @@ -747,7 +748,10 @@ protected function getFiles($dir) {
'bigIcon' => $bigIcon,
'smallIcon' => $smallIcon,
'thumb' => $thumb,
'smallThumb' => $smallThumb
'smallThumb' => $smallThumb,
'width' => $width,
'height' => $height,
'type' => $type
);
}
return $return;
Expand Down
6 changes: 4 additions & 2 deletions js/080.files.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ _.showFiles = function(callBack, selected) {
icon = ".";
icon = "themes/" + _.theme + "/img/files/small/" + icon + ".png";

f = $('<tr class="file"><td class="name thumb"></td><td class="time"></td><td class="size"></td></tr>');
f = $('<tr class="file"><td class="name thumb"></td><td class="time"></td><td class="size"></td><td class="dimensions"></td></tr>');
f.appendTo(c.find('table'));

// Thumbnails
Expand All @@ -76,14 +76,16 @@ _.showFiles = function(callBack, selected) {
if (!icon.length) icon = ".";
icon = "themes/" + _.theme + "/img/files/big/" + icon + ".png";
}
f = $('<div class="file"><div class="thumb"></div><div class="name"></div><div class="time"></div><div class="size"></div></div>');
f = $('<div class="file"><div class="thumb"></div><div class="name"></div><div class="time"></div><div class="size"></div><div class="dimensions"></div></div>');
f.appendTo(c);
}

f.find('.thumb').css({backgroundImage: 'url("' + icon + '")'});
f.find('.name').text(file.name);
f.find('.time').html(file.date);
f.find('.size').html(_.humanSize(file.size));
if(file.type !== false)
f.find('.dimensions').html(file.width + 'x' + file.height + 'px');
f.data(file);

if ((file.name === selected) || $.$.inArray(file.name, selected))
Expand Down
5 changes: 4 additions & 1 deletion themes/dark/03.misc.css
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ div.file .time {
div.file .size {
font-size: 10px;
}
div.file .dimensions {
font-size: 10px;
}
#files div.selected,
#files div.selected:hover {
border-color: #4685b3;
Expand Down Expand Up @@ -443,4 +446,4 @@ div.selector#uniform-lang {
body.msie fieldset,
body.trident.rv fieldset {
border-radius: 0;
}
}
5 changes: 4 additions & 1 deletion themes/default/03.misc.css
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ div.file .time {
div.file .size {
font-size: 10px;
}
div.file .dimensions {
font-size: 10px;
}
#files div.selected,
#files div.selected:hover {
border-color: #3b98d6;
Expand Down Expand Up @@ -428,4 +431,4 @@ a.denied:hover {
body.msie fieldset,
body.trident.rv fieldset {
border-radius: 0;
}
}
2 changes: 2 additions & 0 deletions tpl/tpl_browser.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
<td><label for="showName">&nbsp;<?php echo $this->label("Name") ?></label> &nbsp;</td>
<th><input id="showSize" type="checkbox" name="size" /></th>
<td><label for="showSize">&nbsp;<?php echo $this->label("Size") ?></label> &nbsp;</td>
<th><input id="showDimensions" type="checkbox" name="dimensions" /></th>
<td><label for="showDimensions">&nbsp;<?php echo $this->label("Dimensions") ?></label> &nbsp;</td>
<th><input id="showTime" type="checkbox" name="time" /></th>
<td><label for="showTime">&nbsp;<?php echo $this->label("Date") ?></label></td>
</tr></table>
Expand Down