diff --git a/app/bundles/CoreBundle/Factory/MauticFactory.php b/app/bundles/CoreBundle/Factory/MauticFactory.php index ccb9a29c9f9..39c624ca5d0 100644 --- a/app/bundles/CoreBundle/Factory/MauticFactory.php +++ b/app/bundles/CoreBundle/Factory/MauticFactory.php @@ -389,16 +389,14 @@ public function getSystemPath($name, $fullPath = false) //these are absolute regardless as they are configurable return $this->container->getParameter("kernel.{$name}_dir"); } elseif ($name == 'images') { - $session = $this->getSession(); - $imageDir = $session->get('mautic.imagepath'); + $imageDir = $this->getParameter('image_path'); if (substr($imageDir, -1) === '/') { - $imageDir = substr(0, -1, $imageDir); + $imageDir = substr($imageDir, 0, -1); } - $path = $imageDir; - + return ($fullPath) ? $paths['local_root'] . '/' . $imageDir : $imageDir; } elseif (isset($paths[$name])) { - $path = $paths[$name]; + $path = $paths[$name]; } else { throw new \InvalidArgumentException("$name does not exist."); } @@ -654,7 +652,9 @@ public function getVersion() /** * Get Symfony's logger * - * @return \Symfony\Bridge\Monolog\Logger + * @param bool|false $system + * + * @return object */ public function getLogger($system = false) { diff --git a/app/bundles/CoreBundle/Templating/Helper/GravatarHelper.php b/app/bundles/CoreBundle/Templating/Helper/GravatarHelper.php index b5576719492..e9115e4b433 100644 --- a/app/bundles/CoreBundle/Templating/Helper/GravatarHelper.php +++ b/app/bundles/CoreBundle/Templating/Helper/GravatarHelper.php @@ -11,6 +11,7 @@ use Mautic\CoreBundle\Factory\MauticFactory; use Mautic\CoreBundle\Helper\UrlHelper; +use Mautic\LeadBundle\Templating\Helper\AvatarHelper; use Symfony\Component\Templating\Helper\Helper; /** @@ -34,14 +35,19 @@ class GravatarHelper extends Helper */ private $assetHelper; + /** + * @var AvatarHelper + */ + private $avatarHelper; /** * @param MauticFactory $factory */ public function __construct(MauticFactory $factory) { - $this->devMode = $factory->getEnvironment() == 'dev'; - $this->imageDir = $factory->getSystemPath('images'); - $this->assetHelper = $factory->getHelper('template.assets'); + $this->devMode = $factory->getEnvironment() == 'dev'; + $this->imageDir = $factory->getSystemPath('images'); + $this->assetHelper = $factory->getHelper('template.assets'); + $this->avatarHelper = $factory->getHelper('template.avatar'); } /** @@ -55,7 +61,7 @@ public function getImage($email, $size = '250', $default = null) { $localDefault = ($this->devMode) ? 'https://www.mautic.org/media/images/default_avatar.png' : - $this->assetHelper->getUrl($this->imageDir . '/avatar.png', null, null, true, false); + $this->avatarHelper->getDefaultAvatar(true); $url = 'https://www.gravatar.com/avatar/' . md5(strtolower(trim($email))) . '?s='.$size; if ($default === null) { diff --git a/app/bundles/LeadBundle/Templating/Helper/AvatarHelper.php b/app/bundles/LeadBundle/Templating/Helper/AvatarHelper.php index 34baecfd561..408d6799d1e 100644 --- a/app/bundles/LeadBundle/Templating/Helper/AvatarHelper.php +++ b/app/bundles/LeadBundle/Templating/Helper/AvatarHelper.php @@ -30,6 +30,8 @@ public function __construct (MauticFactory $factory) /** * @param Lead $lead + * + * @return mixed */ public function getAvatar(Lead $lead) { @@ -40,7 +42,13 @@ public function getAvatar(Lead $lead) if ($preferred == 'custom' ) { if ($fmtime = filemtime($this->getAvatarPath(true) . '/avatar'.$lead->getId())) { // Append file modified time to ensure the latest is used by browser - $img = $this->getDefaultAvatar(true); + $img = $this->factory->getHelper('template.assets')->getUrl( + $this->getAvatarPath().'/avatar'.$lead->getId() . '?' . $fmtime, + null, + null, + false, + true + ); } } elseif (isset($socialData[$preferred]) && !empty($socialData[$preferred]['profile']['profileImage'])) { $img = $socialData[$preferred]['profile']['profileImage']; @@ -80,11 +88,10 @@ public function getAvatarPath($absolute = false) public function getDefaultAvatar($absolute = false) { return $this->factory->getHelper('template.assets')->getUrl( - $this->factory->getSystemPath('images').'/avatar.png', + $this->factory->getSystemPath('assets').'/images/avatar.png', null, null, - $absolute, - true + $absolute ); }