aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-06-23 23:13:07 -0700
committerfriendica <info@friendica.com>2013-06-23 23:13:07 -0700
commit5e235fba78e07dc050d5821c3db5bf34466a54d8 (patch)
treeb11d6446ac33071885cd1ca9dc84366813585c73
parentd093981d68477887f5aecbb988bebb451389b79e (diff)
downloadvolse-hubzilla-5e235fba78e07dc050d5821c3db5bf34466a54d8.tar.gz
volse-hubzilla-5e235fba78e07dc050d5821c3db5bf34466a54d8.tar.bz2
volse-hubzilla-5e235fba78e07dc050d5821c3db5bf34466a54d8.zip
make manual image scaling work - even if auto scaling kicks in.
-rw-r--r--include/network.php20
-rw-r--r--include/zot.php2
2 files changed, 14 insertions, 8 deletions
diff --git a/include/network.php b/include/network.php
index f750fcfd8..8b9a8a6a6 100644
--- a/include/network.php
+++ b/include/network.php
@@ -1049,15 +1049,21 @@ function scale_external_images($s, $include_link = true, $scale_replace = false)
$s = htmlspecialchars_decode($s);
$matches = null;
- $c = preg_match_all('/\[img.*?\](.*?)\[\/img\]/ism',$s,$matches,PREG_SET_ORDER);
+ $c = preg_match_all('/\[img(.*?)\](.*?)\[\/img\]/ism',$s,$matches,PREG_SET_ORDER);
if($c) {
require_once('include/photo/photo_driver.php');
foreach($matches as $mtch) {
- logger('scale_external_image: ' . $mtch[1]);
+ logger('scale_external_image: ' . $mtch[1] . ' ' . $mtch[2]);
+
+ if(substr($mtch[1],0,1) == '=') {
+ $owidth = intval(substr($mtch[1],1));
+ if(intval($owidth) > 0 && intval($owidth) < 640)
+ continue;
+ }
$hostname = str_replace('www.','',substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')+3));
- if(stristr($mtch[1],$hostname))
+ if(stristr($mtch[2],$hostname))
continue;
// $scale_replace, if passed, is an array of two elements. The
@@ -1066,9 +1072,9 @@ function scale_external_images($s, $include_link = true, $scale_replace = false)
// This allows Friendica to display the smaller remote image if
// one exists, while still linking to the full-size image
if($scale_replace)
- $scaled = str_replace($scale_replace[0], $scale_replace[1], $mtch[1]);
+ $scaled = str_replace($scale_replace[0], $scale_replace[1], $mtch[2]);
else
- $scaled = $mtch[1];
+ $scaled = $mtch[2];
$i = fetch_url($scaled);
$cache = get_config('system','itemcache');
@@ -1078,7 +1084,7 @@ function scale_external_images($s, $include_link = true, $scale_replace = false)
}
// guess mimetype from headers or filename
- $type = guess_image_type($mtch[1],true);
+ $type = guess_image_type($mtch[2],true);
if($i) {
$ph = photo_factory($i, $type);
@@ -1094,7 +1100,7 @@ function scale_external_images($s, $include_link = true, $scale_replace = false)
logger('scale_external_images: ' . $orig_width . '->' . $new_width . 'w ' . $orig_height . '->' . $new_height . 'h' . ' match: ' . $mtch[0], LOGGER_DEBUG);
$s = str_replace($mtch[0],'[img=' . $new_width . 'x' . $new_height. ']' . $scaled . '[/img]'
. "\n" . (($include_link)
- ? '[zrl=' . $mtch[1] . ']' . t('view full size') . '[/zrl]' . "\n"
+ ? '[zrl=' . $mtch[2] . ']' . t('view full size') . '[/zrl]' . "\n"
: ''),$s);
logger('scale_external_images: new string: ' . $s, LOGGER_DEBUG);
}
diff --git a/include/zot.php b/include/zot.php
index 79031ab26..689af2dac 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -1040,7 +1040,7 @@ function process_delivery($sender,$arr,$deliveries,$relay) {
continue;
}
- // for events, extract the event info and create and event linked to an item
+ // for events, extract the event info and create an event linked to an item
if((x($arr,'obj_type')) && (activity_match($arr['obj_type'],ACTIVITY_OBJ_EVENT))) {
require_once('include/event.php');