aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kostikov <max@kostikov.co>2018-12-17 12:28:58 +0000
committerMario <mario@mariovavti.com>2018-12-22 20:04:09 +0100
commit01448c152c95bdb90b429710498d034f127983d1 (patch)
tree74da140bb13ce157867c7ff7dc411f4d9f5d0b36
parenta09beb38335d3dff6d4d414027791a30a1cef684 (diff)
downloadvolse-hubzilla-01448c152c95bdb90b429710498d034f127983d1.tar.gz
volse-hubzilla-01448c152c95bdb90b429710498d034f127983d1.tar.bz2
volse-hubzilla-01448c152c95bdb90b429710498d034f127983d1.zip
Remove scale_external_images()
(cherry picked from commit 1541f67eab5f541d1f61001fc4e42132a9ac09f8)
-rw-r--r--include/network.php93
1 files changed, 0 insertions, 93 deletions
diff --git a/include/network.php b/include/network.php
index a9a7cd03e..5f45d8eb8 100644
--- a/include/network.php
+++ b/include/network.php
@@ -706,99 +706,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/