generate all (non-square) photo scales - even if the original photo is smaller than the scale target sizes.
This commit is contained in:
parent
d9753989bf
commit
bf5a1f662a
@ -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
|
* photo_rand - display a random photo from one of your photo albums. Photo permissions are honoured
|
||||||
* args:
|
* args:
|
||||||
* album - album name (very strongly recommended if you have lots of photos)
|
* 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
|
* style - CSS style string
|
||||||
* channel_id - if not your own
|
* channel_id - if not your own
|
||||||
<br /> <br />
|
<br /> <br />
|
||||||
|
@ -586,7 +586,7 @@ function scale_external_images($s, $include_link = true, $scale_replace = false)
|
|||||||
|
|
||||||
if(substr($mtch[1],0,1) == '=') {
|
if(substr($mtch[1],0,1) == '=') {
|
||||||
$owidth = intval(substr($mtch[2],1));
|
$owidth = intval(substr($mtch[2],1));
|
||||||
if(intval($owidth) > 0 && intval($owidth) < 640)
|
if(intval($owidth) > 0 && intval($owidth) < 1024)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -624,9 +624,9 @@ function scale_external_images($s, $include_link = true, $scale_replace = false)
|
|||||||
$orig_width = $ph->getWidth();
|
$orig_width = $ph->getWidth();
|
||||||
$orig_height = $ph->getHeight();
|
$orig_height = $ph->getHeight();
|
||||||
|
|
||||||
if($orig_width > 640 || $orig_height > 640) {
|
if($orig_width > 1024 || $orig_height > 1024) {
|
||||||
$tag = (($match[1] == 'z') ? 'zmg' : 'img');
|
$tag = (($match[1] == 'z') ? 'zmg' : 'img');
|
||||||
$ph->scaleImage(640);
|
$ph->scaleImage(1024);
|
||||||
$new_width = $ph->getWidth();
|
$new_width = $ph->getWidth();
|
||||||
$new_height = $ph->getHeight();
|
$new_height = $ph->getHeight();
|
||||||
logger('scale_external_images: ' . $orig_width . '->' . $new_width . 'w ' . $orig_height . '->' . $new_height . 'h' . ' match: ' . $mtch[0], LOGGER_DEBUG);
|
logger('scale_external_images: ' . $orig_width . '->' . $new_width . 'w ' . $orig_height . '->' . $new_height . 'h' . ' match: ' . $mtch[0], LOGGER_DEBUG);
|
||||||
|
@ -193,32 +193,32 @@ function photo_upload($channel, $observer, $args) {
|
|||||||
unset($p['os_storage']);
|
unset($p['os_storage']);
|
||||||
unset($p['os_path']);
|
unset($p['os_path']);
|
||||||
|
|
||||||
if(($width > 1024 || $height > 1024) && (! $errors)) {
|
if(($width > 1024 || $height > 1024) && (! $errors))
|
||||||
$ph->scaleImage(1024);
|
$ph->scaleImage(1024);
|
||||||
|
|
||||||
$p['scale'] = 1;
|
$p['scale'] = 1;
|
||||||
$r2 = $ph->save($p);
|
$r2 = $ph->save($p);
|
||||||
$smallest = 1;
|
$smallest = 1;
|
||||||
if(! $r2)
|
if(! $r2)
|
||||||
$errors = true;
|
$errors = true;
|
||||||
}
|
|
||||||
|
|
||||||
if(($width > 640 || $height > 640) && (! $errors)) {
|
if(($width > 640 || $height > 640) && (! $errors))
|
||||||
$ph->scaleImage(640);
|
$ph->scaleImage(640);
|
||||||
|
|
||||||
$p['scale'] = 2;
|
$p['scale'] = 2;
|
||||||
$r3 = $ph->save($p);
|
$r3 = $ph->save($p);
|
||||||
$smallest = 2;
|
$smallest = 2;
|
||||||
if(! $r3)
|
if(! $r3)
|
||||||
$errors = true;
|
$errors = true;
|
||||||
}
|
|
||||||
|
|
||||||
if(($width > 320 || $height > 320) && (! $errors)) {
|
if(($width > 320 || $height > 320) && (! $errors))
|
||||||
$ph->scaleImage(320);
|
$ph->scaleImage(320);
|
||||||
|
|
||||||
$p['scale'] = 3;
|
$p['scale'] = 3;
|
||||||
$r3 = $ph->save($p);
|
$r3 = $ph->save($p);
|
||||||
$smallest = 3;
|
$smallest = 3;
|
||||||
if(! $r3)
|
if(! $r3)
|
||||||
$errors = true;
|
$errors = true;
|
||||||
}
|
|
||||||
|
|
||||||
if($errors) {
|
if($errors) {
|
||||||
q("delete from photo where resource_id = '%s' and uid = %d",
|
q("delete from photo where resource_id = '%s' and uid = %d",
|
||||||
|
@ -253,8 +253,9 @@ function photos_post(&$a) {
|
|||||||
intval($page_owner_uid)
|
intval($page_owner_uid)
|
||||||
);
|
);
|
||||||
|
|
||||||
if($width > 1024 || $height > 1024) {
|
if($width > 1024 || $height > 1024)
|
||||||
$ph->scaleImage(1024);
|
$ph->scaleImage(1024);
|
||||||
|
|
||||||
$width = $ph->getWidth();
|
$width = $ph->getWidth();
|
||||||
$height = $ph->getHeight();
|
$height = $ph->getHeight();
|
||||||
|
|
||||||
@ -265,10 +266,11 @@ function photos_post(&$a) {
|
|||||||
dbesc($resource_id),
|
dbesc($resource_id),
|
||||||
intval($page_owner_uid)
|
intval($page_owner_uid)
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
if($width > 640 || $height > 640) {
|
|
||||||
|
if($width > 640 || $height > 640)
|
||||||
$ph->scaleImage(640);
|
$ph->scaleImage(640);
|
||||||
|
|
||||||
$width = $ph->getWidth();
|
$width = $ph->getWidth();
|
||||||
$height = $ph->getHeight();
|
$height = $ph->getHeight();
|
||||||
|
|
||||||
@ -279,10 +281,11 @@ function photos_post(&$a) {
|
|||||||
dbesc($resource_id),
|
dbesc($resource_id),
|
||||||
intval($page_owner_uid)
|
intval($page_owner_uid)
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
if($width > 320 || $height > 320) {
|
|
||||||
|
if($width > 320 || $height > 320)
|
||||||
$ph->scaleImage(320);
|
$ph->scaleImage(320);
|
||||||
|
|
||||||
$width = $ph->getWidth();
|
$width = $ph->getWidth();
|
||||||
$height = $ph->getHeight();
|
$height = $ph->getHeight();
|
||||||
|
|
||||||
@ -296,7 +299,9 @@ function photos_post(&$a) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// @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",
|
$p = q("SELECT * FROM `photo` WHERE `resource_id` = '%s' AND `uid` = %d ORDER BY `scale` DESC",
|
||||||
dbesc($resource_id),
|
dbesc($resource_id),
|
||||||
|
Reference in New Issue
Block a user