aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2018-12-18 10:17:57 +0100
committerMario <mario@mariovavti.com>2018-12-18 10:17:57 +0100
commit6fc8c174f911b09382b3e106243128096cef9f49 (patch)
tree2231ebc3974ec98476168e85ead5b86baac23620 /include
parent63b205c601c8ff567407155c327515bb0c5165b3 (diff)
parent3a662555768840d18c6dbba027af644eda54f20e (diff)
downloadvolse-hubzilla-6fc8c174f911b09382b3e106243128096cef9f49.tar.gz
volse-hubzilla-6fc8c174f911b09382b3e106243128096cef9f49.tar.bz2
volse-hubzilla-6fc8c174f911b09382b3e106243128096cef9f49.zip
Merge branch 'dev' into 'dev'
Remove scale_external_images() See merge request hubzilla/core!1441
Diffstat (limited to 'include')
-rw-r--r--include/markdown.php2
-rw-r--r--include/network.php93
-rw-r--r--include/text.php2
3 files changed, 0 insertions, 97 deletions
diff --git a/include/markdown.php b/include/markdown.php
index 64f0a0854..2513a7d77 100644
--- a/include/markdown.php
+++ b/include/markdown.php
@@ -91,8 +91,6 @@ function markdown_to_bb($s, $use_zrl = false, $options = []) {
// remove duplicate adjacent code tags
$s = preg_replace("/(\[code\])+(.*?)(\[\/code\])+/ism","[code]$2[/code]", $s);
- // Don't show link to full picture (until it is fixed)
- $s = scale_external_images($s, false);
/**
* @hooks markdown_to_bb
diff --git a/include/network.php b/include/network.php
index df59a30e6..65770221f 100644
--- a/include/network.php
+++ b/include/network.php
@@ -710,99 +710,6 @@ function sxml2array ( $xmlObject, $out = array () )
/**
- * @brief Scales an external image.
- *
- * @param string $s
- * @param string $include_link default true
- * @param string $scale_replace default false
- * @return string
- */
-function scale_external_images($s, $include_link = true, $scale_replace = false) {
-
- // Picture addresses can contain special characters
- $s = htmlspecialchars_decode($s, ENT_COMPAT);
-
- $matches = null;
- $c = preg_match_all('/\[([zi])mg(.*?)\](.*?)\[\/[zi]mg\]/ism', $s, $matches, PREG_SET_ORDER);
- if($c) {
- require_once('include/photo/photo_driver.php');
-
- foreach($matches as $mtch) {
- logger('data: ' . $mtch[2] . ' ' . $mtch[3]);
-
- if(substr($mtch[2],0,1) == '=') {
- $owidth = intval(substr($mtch[2],1));
- if($owidth > 0 && $owidth < 1024)
- continue;
- }
-
- $hostname = str_replace('www.','',substr(z_root(),strpos(z_root(),'://')+3));
- if(stristr($mtch[3],$hostname))
- continue;
-
- // $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[3]);
- else
- $scaled = $mtch[3];
-
- if(! strpbrk(substr($scaled, 0, 1), 'zhfmt'))
- continue;
-
- $i = z_fetch_url($scaled, true);
-
- $cache = get_config('system', 'itemcache');
- if (($cache != '') and is_dir($cache)) {
- $cachefile = $cache . '/' . hash('md5', $scaled);
- file_put_contents($cachefile, $i['body']);
- }
-
- // guess mimetype from headers or filename
-
- $type = guess_image_type($mtch[3], $i['header']);
- if(strpos($type, 'image') === false)
- continue;
-
- if($i['success']) {
- $ph = photo_factory($i['body'], $type);
-
- if(! is_object($ph))
- continue;
-
- if($ph->is_valid()) {
- $orig_width = $ph->getWidth();
- $orig_height = $ph->getHeight();
-
- if($orig_width > 1024 || $orig_height > 1024) {
- $tag = (($match[1] == 'z') ? 'zmg' : 'img');
- $linktag = (($match[1] == 'z') ? 'zrl' : 'url');
- $ph->scaleImage(1024);
- $new_width = $ph->getWidth();
- $new_height = $ph->getHeight();
- logger('data: ' . $orig_width . '->' . $new_width . 'w ' . $orig_height . '->' . $new_height . 'h' . ' match: ' . $mtch[0], LOGGER_DEBUG);
- $s = str_replace($mtch[0],'[' . $tag . '=' . $new_width . 'x' . $new_height. ']' . $scaled . '[/' . $tag . ']'
- . "\n" . (($include_link)
- ? '[' . $linktag . '=' . $mtch[3] . ']' . t('view full size') . '[/' . $linktag . ']' . "\n"
- : ''),$s);
- logger('new string: ' . $s, LOGGER_DEBUG);
- }
- }
- }
- }
- }
-
- // replace the special char encoding
-
- $s = htmlspecialchars($s, ENT_COMPAT, 'UTF-8');
-
- return $s;
-}
-
-/**
* @brief xml2array() will convert the given XML text to an array in the XML structure.
*
* Link: http://www.bin-co.com/php/scripts/xml2array/
diff --git a/include/text.php b/include/text.php
index bd0d8048d..3cc21e4ce 100644
--- a/include/text.php
+++ b/include/text.php
@@ -3305,8 +3305,6 @@ function cleanup_bbcode($body) {
$body = preg_replace('/\[\/code\]\s*\[code\]/ism',"\n",$body);
- $body = scale_external_images($body, false);
-
return $body;
}