Skip to content

Commit

Permalink
Aditional check for external missing avatars
Browse files Browse the repository at this point in the history
Aditional check for external linked avatars.
Without the code, external linked avatars not available are shown without the default avatar
  • Loading branch information
rica-carv authored Apr 27, 2024
1 parent bdbda01 commit 65fc765
Showing 1 changed file with 25 additions and 40 deletions.
65 changes: 25 additions & 40 deletions e107_handlers/e_parse_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@ class e_parse

protected $staticUrl;

protected $staticUrlMap = [];

/** @var array Stored relative paths - used by replaceConstants() */
private $relativePaths = [];
private $relativePaths = array();


// BBcode that contain preformatted code.
Expand Down Expand Up @@ -256,8 +254,6 @@ class e_parse
private $bootstrap;
private $fontawesome;

private $modRewriteMedia;

private $removedList = array();
private $nodesToDelete = array();
private $nodesToConvert = array();
Expand Down Expand Up @@ -2424,36 +2420,26 @@ public function staticUrl($path = null, $opts = array())
}

$staticArray = $this->staticUrl; // e_HTTP_STATIC;
$path = $this->replaceConstants($path, 'abs'); // replace any {THEME} etc.
$key = ltrim(eHelper::dasherize($path), '/');

if (is_array($staticArray))
{
if(!empty($this->staticUrlMap[$key]))
$cnt = count($staticArray);
$staticCount = $this->staticCount();
if ($staticCount > ($cnt - 1))
{
$http = $this->staticUrlMap[$key];
$staticCount = 0;
$this->staticCount(0);
}
else
{
$cnt = count($staticArray);
$staticCount = $this->staticCount();
if ($staticCount > ($cnt - 1))
{
$staticCount = 0;
$this->staticCount(0);
}

$http = !empty($staticArray[$staticCount]) ? $staticArray[$staticCount] : e_HTTP;
$this->staticCount(1);
}
$http = !empty($staticArray[$staticCount]) ? $staticArray[$staticCount] : e_HTTP;

}
else
{
$http = $this->staticUrl;
}

$this->staticUrlMap[$key] = $http;

$this->staticCount(1);

if (empty($path))
{
Expand All @@ -2462,7 +2448,7 @@ public function staticUrl($path = null, $opts = array())

$base = '';


$path = $this->replaceConstants($path, 'abs'); // replace any {THEME} etc.

$srch = array(
e_PLUGIN_ABS,
Expand Down Expand Up @@ -2490,8 +2476,6 @@ public function staticUrl($path = null, $opts = array())
$ret = str_replace(e_MEDIA_ABS, $http . $base . e107::getFolder('media'), $ret);
}



return $ret;

}
Expand All @@ -2503,12 +2487,8 @@ public function staticUrl($path = null, $opts = array())
*/
public function setStaticUrl($url)
{
$this->staticUrl = $url;
}

public function getStaticUrlMap()
{
return $this->staticUrlMap;
$this->staticUrl = $url;
}

/**
Expand Down Expand Up @@ -2656,10 +2636,10 @@ public function thumbUrl($url = null, $options = array(), $raw = false, $full =
}


if ($this->modRewriteMedia && empty($options['nosef']))// SEF URL support.
if (e_MOD_REWRITE_MEDIA == true && empty($options['nosef']))// Experimental SEF URL support.
{
$options['full'] = $full;
$options['ext'] = pathinfo($url, PATHINFO_EXTENSION);
$options['ext'] = substr($url, -3);
$options['thurl'] = $thurl;
// $options['x'] = $this->thumbEncode();

Expand Down Expand Up @@ -3626,9 +3606,8 @@ public function init()
if (defined('BOOTSTRAP'))
{
$this->bootstrap = (int) BOOTSTRAP;
}

$this->modRewriteMedia = deftrue('e_MOD_REWRITE_MEDIA');
}

if (defined('e_HTTP_STATIC'))
{
Expand Down Expand Up @@ -3802,6 +3781,7 @@ public function setScriptTags($array = array())
*/
public function setFontAwesome($version)
{

$this->fontawesome = (int) $version;
}

Expand All @@ -3810,13 +3790,10 @@ public function setFontAwesome($version)
*/
public function setBootstrap($version)
{

$this->bootstrap = (int) $version;
}

public function setmodRewriteMedia($bool)
{
$this->modRewriteMedia = (bool) $bool;
}

/**
* Add leading zeros to a number. eg. 3 might become 000003
Expand Down Expand Up @@ -4315,7 +4292,15 @@ public function toAvatar($userData = null, $options = array())

if (strpos($image, '://') !== false) // Remote Image
{
$url = $image;
if (file_exists($image))
{
$url = $image;
}
else
{
$file = $genericFile;
$url = $genericImg;
}
}
elseif (strpos($image, '-upload-') === 0)
{
Expand Down

0 comments on commit 65fc765

Please sign in to comment.