aboutsummaryrefslogtreecommitdiffstats
path: root/include/network.php
diff options
context:
space:
mode:
authorVasudev Kamath <kamathvasudev@gmail.com>2012-07-06 22:47:27 +0530
committerVasudev Kamath <kamathvasudev@gmail.com>2012-07-06 22:47:27 +0530
commitba4db236ecff1ffdb56adc2715b3f53515f8cb34 (patch)
treef0b9928aade8aab95d1608890fde1918ce163754 /include/network.php
parent6e4760dd9c512147309b5e4a98d25216610f81da (diff)
parenta122fecf50d06856a2ada8b564f711fb52c327f0 (diff)
downloadvolse-hubzilla-ba4db236ecff1ffdb56adc2715b3f53515f8cb34.tar.gz
volse-hubzilla-ba4db236ecff1ffdb56adc2715b3f53515f8cb34.tar.bz2
volse-hubzilla-ba4db236ecff1ffdb56adc2715b3f53515f8cb34.zip
Merge branch 'master' of git://github.com/friendica/friendica
Diffstat (limited to 'include/network.php')
-rw-r--r--include/network.php21
1 files changed, 18 insertions, 3 deletions
diff --git a/include/network.php b/include/network.php
index 446413cd8..9e6f8355b 100644
--- a/include/network.php
+++ b/include/network.php
@@ -607,6 +607,9 @@ function validate_url(&$url) {
if(! function_exists('validate_email')) {
function validate_email($addr) {
+ if(get_config('system','disable_email_validation'))
+ return true;
+
if(! strpos($addr,'@'))
return false;
$h = substr($addr,strpos($addr,'@') + 1);
@@ -793,7 +796,7 @@ function add_fcontact($arr,$update = false) {
}
-function scale_external_images($s,$include_link = true) {
+function scale_external_images($s, $include_link = true, $scale_replace = false) {
$a = get_app();
@@ -803,10 +806,22 @@ function scale_external_images($s,$include_link = true) {
require_once('include/Photo.php');
foreach($matches as $mtch) {
logger('scale_external_image: ' . $mtch[1]);
+
$hostname = str_replace('www.','',substr($a->get_baseurl(),strpos($a->get_baseurl(),'://')+3));
if(stristr($mtch[1],$hostname))
continue;
- $i = fetch_url($mtch[1]);
+
+ // $scale_replace, if passed, is an array of two elements. The
+ // first is the name of the full-size image. The second is the
+ // name of a remote, scaled-down version of the full size image.
+ // 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]);
+ else
+ $scaled = $mtch[1];
+ $i = fetch_url($scaled);
+
// guess mimetype from headers or filename
$type = guess_image_type($mtch[1],true);
@@ -822,7 +837,7 @@ function scale_external_images($s,$include_link = true) {
$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);
- $s = str_replace($mtch[0],'[img=' . $new_width . 'x' . $new_height. ']' . $mtch[1] . '[/img]'
+ $s = str_replace($mtch[0],'[img=' . $new_width . 'x' . $new_height. ']' . $scaled . '[/img]'
. "\n" . (($include_link)
? '[url=' . $mtch[1] . ']' . t('view full size') . '[/url]' . "\n"
: ''),$s);