aboutsummaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--doc/Widgets.md2
-rw-r--r--include/network.php6
-rw-r--r--include/photos.php42
-rw-r--r--mod/photos.php77
4 files changed, 66 insertions, 61 deletions
diff --git a/doc/Widgets.md b/doc/Widgets.md
index a225f5ef3..7acd9241b 100644
--- a/doc/Widgets.md
+++ b/doc/Widgets.md
@@ -88,7 +88,7 @@ Some/many of these widgets have restrictions which may restrict the type of page
* photo_rand - display a random photo from one of your photo albums. Photo permissions are honoured
* args:
* album - album name (very strongly recommended if you have lots of photos)
- * scale - typically 0 (original size), 1 (640px), or 2 (320px)
+ * scale - typically 0 (original size), 1 (1024px), 2, (640px), or 3 (320px)
* style - CSS style string
* channel_id - if not your own
<br />&nbsp;<br />
diff --git a/include/network.php b/include/network.php
index 41e1ff37c..e1793b405 100644
--- a/include/network.php
+++ b/include/network.php
@@ -586,7 +586,7 @@ function scale_external_images($s, $include_link = true, $scale_replace = false)
if(substr($mtch[1],0,1) == '=') {
$owidth = intval(substr($mtch[2],1));
- if(intval($owidth) > 0 && intval($owidth) < 640)
+ if(intval($owidth) > 0 && intval($owidth) < 1024)
continue;
}
@@ -624,9 +624,9 @@ function scale_external_images($s, $include_link = true, $scale_replace = false)
$orig_width = $ph->getWidth();
$orig_height = $ph->getHeight();
- if($orig_width > 640 || $orig_height > 640) {
+ if($orig_width > 1024 || $orig_height > 1024) {
$tag = (($match[1] == 'z') ? 'zmg' : 'img');
- $ph->scaleImage(640);
+ $ph->scaleImage(1024);
$new_width = $ph->getWidth();
$new_height = $ph->getHeight();
logger('scale_external_images: ' . $orig_width . '->' . $new_width . 'w ' . $orig_height . '->' . $new_height . 'h' . ' match: ' . $mtch[0], LOGGER_DEBUG);
diff --git a/include/photos.php b/include/photos.php
index 2fc25b4bf..618f36fb1 100644
--- a/include/photos.php
+++ b/include/photos.php
@@ -193,32 +193,32 @@ function photo_upload($channel, $observer, $args) {
unset($p['os_storage']);
unset($p['os_path']);
- if(($width > 1024 || $height > 1024) && (! $errors)) {
+ if(($width > 1024 || $height > 1024) && (! $errors))
$ph->scaleImage(1024);
- $p['scale'] = 1;
- $r2 = $ph->save($p);
- $smallest = 1;
- if(! $r2)
- $errors = true;
- }
- if(($width > 640 || $height > 640) && (! $errors)) {
+ $p['scale'] = 1;
+ $r2 = $ph->save($p);
+ $smallest = 1;
+ if(! $r2)
+ $errors = true;
+
+ if(($width > 640 || $height > 640) && (! $errors))
$ph->scaleImage(640);
- $p['scale'] = 2;
- $r3 = $ph->save($p);
- $smallest = 2;
- if(! $r3)
- $errors = true;
- }
- if(($width > 320 || $height > 320) && (! $errors)) {
+ $p['scale'] = 2;
+ $r3 = $ph->save($p);
+ $smallest = 2;
+ if(! $r3)
+ $errors = true;
+
+ if(($width > 320 || $height > 320) && (! $errors))
$ph->scaleImage(320);
- $p['scale'] = 3;
- $r3 = $ph->save($p);
- $smallest = 3;
- if(! $r3)
- $errors = true;
- }
+
+ $p['scale'] = 3;
+ $r3 = $ph->save($p);
+ $smallest = 3;
+ if(! $r3)
+ $errors = true;
if($errors) {
q("delete from photo where resource_id = '%s' and uid = %d",
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)