aboutsummaryrefslogtreecommitdiffstats
path: root/mod
diff options
context:
space:
mode:
authorredmatrix <redmatrix@redmatrix.me>2015-10-15 14:18:40 -0700
committerredmatrix <redmatrix@redmatrix.me>2015-10-15 14:18:40 -0700
commitbf5a1f662a4f00e8376613fa387c843d539c7433 (patch)
tree8077cf749de57edd83885859698c27dba9f6a31a /mod
parentd9753989bf63047051bc0fbfc6e2b438040acf85 (diff)
downloadvolse-hubzilla-bf5a1f662a4f00e8376613fa387c843d539c7433.tar.gz
volse-hubzilla-bf5a1f662a4f00e8376613fa387c843d539c7433.tar.bz2
volse-hubzilla-bf5a1f662a4f00e8376613fa387c843d539c7433.zip
generate all (non-square) photo scales - even if the original photo is smaller than the scale target sizes.
Diffstat (limited to 'mod')
-rw-r--r--mod/photos.php77
1 files changed, 41 insertions, 36 deletions
diff --git a/mod/photos.php b/mod/photos.php
index 4b392a288..e484880e3 100644
--- a/mod/photos.php
+++ b/mod/photos.php
@@ -253,51 +253,56 @@ function photos_post(&$a) {
intval($page_owner_uid)
);
- if($width > 1024 || $height > 1024) {
+ if($width > 1024 || $height > 1024)
$ph->scaleImage(1024);
- $width = $ph->getWidth();
- $height = $ph->getHeight();
-
- $x = q("update photo set data = '%s', height = %d, width = %d where `resource_id` = '%s' and uid = %d and scale = 1",
- dbescbin($ph->imageString()),
- intval($height),
- intval($width),
- dbesc($resource_id),
- intval($page_owner_uid)
- );
- }
- if($width > 640 || $height > 640) {
+ $width = $ph->getWidth();
+ $height = $ph->getHeight();
+
+ $x = q("update photo set data = '%s', height = %d, width = %d where `resource_id` = '%s' and uid = %d and scale = 1",
+ dbescbin($ph->imageString()),
+ intval($height),
+ intval($width),
+ dbesc($resource_id),
+ intval($page_owner_uid)
+ );
+
+
+ if($width > 640 || $height > 640)
$ph->scaleImage(640);
- $width = $ph->getWidth();
- $height = $ph->getHeight();
-
- $x = q("update photo set data = '%s', height = %d, width = %d where `resource_id` = '%s' and uid = %d and scale = 2",
- dbescbin($ph->imageString()),
- intval($height),
- intval($width),
- dbesc($resource_id),
- intval($page_owner_uid)
- );
- }
- if($width > 320 || $height > 320) {
+ $width = $ph->getWidth();
+ $height = $ph->getHeight();
+
+ $x = q("update photo set data = '%s', height = %d, width = %d where `resource_id` = '%s' and uid = %d and scale = 2",
+ dbescbin($ph->imageString()),
+ intval($height),
+ intval($width),
+ dbesc($resource_id),
+ intval($page_owner_uid)
+ );
+
+
+ if($width > 320 || $height > 320)
$ph->scaleImage(320);
- $width = $ph->getWidth();
- $height = $ph->getHeight();
-
- $x = q("update photo set data = '%s', height = %d, width = %d where `resource_id` = '%s' and uid = %d and scale = 3",
- dbescbin($ph->imageString()),
- intval($height),
- intval($width),
- dbesc($resource_id),
- intval($page_owner_uid)
- );
- }
+
+ $width = $ph->getWidth();
+ $height = $ph->getHeight();
+
+ $x = q("update photo set data = '%s', height = %d, width = %d where `resource_id` = '%s' and uid = %d and scale = 3",
+ dbescbin($ph->imageString()),
+ intval($height),
+ intval($width),
+ dbesc($resource_id),
+ intval($page_owner_uid)
+ );
}
}
}
+ // @FIXME This query includes data of all thumbnails and could probably
+ // be made much more memory efficient.
+
$p = q("SELECT * FROM `photo` WHERE `resource_id` = '%s' AND `uid` = %d ORDER BY `scale` DESC",
dbesc($resource_id),
intval($page_owner_uid)