Logo Image Broken Due To Image Hosted On "HTTP" URL - Question | JoomShaper

Logo Image Broken Due To Image Hosted On "HTTP" URL

F

Fuze1

Helix Framework 1 year ago

Hi,

I've recently started using Cloudflare and since using their SSL Certificates, I've noticed that the logos on my client sites (using Helix Framework) all break due to image being sent over a HTTP URL, rather than a HTTPS URL.

All other image URL's on the websites have been automatically updated to HTTPS url's. It's just the logos which haven't.

I've tried re-uploading the logos and also tried changing them from SVG's to PNG, but no joy unfortunately. Please advise how I can fix this?

Thanks

0
12 Answers
Toufiq
Toufiq
Accepted Answer
Senior Staff 1 year ago #165548

templates/shaper_helixultimate/feature/logo.php

Logo doesn’t work if you use HTTPS on your site.

Solution

<?php
/**
 * @package Helix_Ultimate_Framework
 * @author JoomShaper <[email protected]>
 * Copyright (c) 2010 - 2021 JoomShaper
 * @license www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or Later
 */

defined('_JEXEC') or die();

use HelixUltimate\Framework\Platform\Helper;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Uri\Uri;

/**
 * Helix Ultimate Site Logo.
 *
 * @since   1.0.0
 */
class HelixUltimateFeatureLogo
{
    /**
     * Template parameters
     *
     * @var     object  $params     The parameters object
     * @since   1.0.0
     */
    private $params;
    public $position;
    public $load_pos;

    /**
     * Constructor function
     *
     * @param   object  $params     The template parameters
     *
     * @since   1.0.0
     */
    public function __construct($params)
    {
        $this->params = $params;
        $this->position = 'logo';
        $this->load_pos = $this->params->get('logo_load_pos', 'default');
    }

    /**
     * Render the logo features.
     * 
     * @param boolean $isToggle     Will show toggler if true
     *
     * @return  string
     * @since   1.0.0
     */
    public function renderFeature($isToggle = true)
    {

        $template_name = HelixUltimate\Framework\Platform\Helper::loadTemplateData()->template;

        $menu_type = $this->params->get('menu_type');
        $offcanvas_position = $this->params->get('offcanvas_position', 'right');

        $doc = Factory::getDocument();

        $presetVars = (array) json_decode(Helper::CheckNull($this->params->get('preset')));
        $preset = (isset($presetVars['preset']) && $presetVars['preset']) ? $presetVars['preset'] : 'default';

        $html = '';

        if ($isToggle && $offcanvas_position === 'left')
        {
            if ($menu_type === 'mega')
            {
                $html .= '<a id="offcanvas-toggler" aria-label="' . Text::_('HELIX_ULTIMATE_NAVIGATION') . '" class="offcanvas-toggler-left d-flex d-lg-none" href="#" aria-hidden="true" title="' . Text::_('HELIX_ULTIMATE_NAVIGATION') . '"><div class="burger-icon"><span></span><span></span><span></span></div></a>';
            }
            else
            {
                $html .= '<a id="offcanvas-toggler" aria-label="' . Text::_('HELIX_ULTIMATE_NAVIGATION') . '" class="offcanvas-toggler-left d-flex align-items-center" href="#" aria-hidden="true" title="' . Text::_('HELIX_ULTIMATE_NAVIGATION') . '"><div class="burger-icon"><span></span><span></span><span></span></div></a>';
            }
        }

        $custom_logo_class = '';
        $sitename = Factory::getApplication()->get('sitename');

        if ($this->params->get('mobile_logo'))
        {
            $custom_logo_class = ' d-none d-lg-inline-block';
        }

        if ($this->params->get('logo_type') === 'image')
        {
            $altText = $this->params->get('logo_alt', $sitename);

            if ($this->params->get('logo_image'))
            {
                $logoUrl = $this->params->get('logo_custom_link') ?? Uri::base(true) . '/';

                $html .= '<div class="logo">';
                $html .= '<a href="' . $logoUrl . '">';

                $defaultLogo = $this->params->get('logo_image', null);
                $retinaLogo = $this->params->get('retina_logo', null);
                $srcset = '';
                if (file_exists($defaultLogo))
                {
                    $srcset .= Uri::root() . $defaultLogo . ' 1x';
                }
                if (file_exists($defaultLogo) && (!is_null($retinaLogo) && file_exists($retinaLogo)))
                {
                    $srcset .= ', ';
                }
                if (!is_null($retinaLogo) && file_exists($retinaLogo))
                {
                    $srcset .= Uri::root() . $retinaLogo . ' 2x';
                }
                $attrLogoHeight = $this->params->get('logo_height', '0px');
                $logoWithUrl = str_replace('', '', Uri::root() . $defaultLogo);
                $srcset = str_replace('', '', $srcset);

                $siteLogo = "
                <img class='logo-image {$custom_logo_class}'
                    srcset='{$srcset}'
                    src='{$logoWithUrl}'
                    height='{$attrLogoHeight}'
                    alt='{$altText}'
                />
                ";

                $html .= $siteLogo;

                if ($this->params->get('mobile_logo'))
                {
                    $html .= '<img class="logo-image-phone d-inline-block d-lg-none" src="' .
                        Uri::root() .$this->params->get('mobile_logo') . '" alt="' . $altText . '" />';
                }

                $html .= '</a>';

                $html .= '</div>';
            }
            else
            {
                $html .= '<div class="logo">';
                $html .= '<a href="' . Uri::base(true) . '/">';

                $html .= '<img class="logo-image' . $custom_logo_class .
                    '" src="' . Uri::base() . 'templates/' .
                    $template_name . '/images/presets/' . $preset . '/logo.svg" alt="' . $altText . '" />';

                if ($this->params->get('mobile_logo'))
                {
                    $html .= '<img class="logo-image-phone d-inline-block d-lg-none" src="' . $this->params->get('mobile_logo') . '" alt="' . $altText . '" />';
                }

                $html .= '</a>';
                $html .= '</div>';
            }

            if ($logo_height = $this->params->get('logo_height', ''))
            {
                $logo_height = preg_match("@(px|em|rem|%)$@", $logo_height) ? $logo_height : $logo_height . 'px';

                $logoStyle = '.logo-image {height:' . $logo_height . ';}';
                $logoStyle .= '.logo-image-phone {height:' . $logo_height . ';}';

                $doc->addStyleDeclaration($logoStyle);
            }

            /**
             * If responsive logo height is provided then add the height
             * to the media query.
             */
            if ($logo_height_sm = $this->params->get('logo_height_sm', ''))
            {
                $logo_height_sm = preg_match("@(px|em|rem|%)$@", $logo_height_sm) ? $logo_height_sm : $logo_height_sm . 'px';

                $logoStyleSm = '@media(max-width: 992px) {';
                $logoStyleSm .= '.logo-image {height: ' . $logo_height_sm . ';}';
                $logoStyleSm .= '.logo-image-phone {height: ' . $logo_height_sm . ';}';
                $logoStyleSm .= '}';

                $doc->addStyleDeclaration($logoStyleSm);
            }

            if ($logo_height_xs = $this->params->get('logo_height_xs', ''))
            {
                $logo_height_xs = preg_match("@(px|em|rem|%)$@", $logo_height_xs) ? $logo_height_xs : $logo_height_xs . 'px';

                $logoStyleXs = '@media(max-width: 576px) {';
                $logoStyleXs .= '.logo-image {height: ' . $logo_height_xs . ';}';
                $logoStyleXs .= '.logo-image-phone {height: ' . $logo_height_xs . ';}';
                $logoStyleXs .= '}';

                $doc->addStyleDeclaration($logoStyleXs);
            }
        }
        else
        {
            if ($this->params->get('logo_text'))
            {
                $html .= '<span class="logo"><a href="' . Uri::base(true) . '/">' . $this->params->get('logo_text') . '</a></span>';
            }
            else
            {
                $html .= '<span class="logo"><a href="' . Uri::base(true) . '/">' . $sitename . '</a></span>';
            }

            if ($this->params->get('logo_slogan'))
            {
                $html .= '<span class="logo-slogan">' . $this->params->get('logo_slogan') . '</span>';
            }
        }

        return $html;
    }
}
1
Ofi Khan
Ofi Khan
Accepted Answer
Support Agent 1 year ago #165472

Hello Fuze1

Apology for the inconvenience. Please share your administrator access here to check the issue. Use the Hidden Content box to share the credentials. Make sure that you have a full site backup with you before sharing.

Best regards

0
Toufiq
Toufiq
Accepted Answer
Senior Staff 1 year ago #165473

Hi there,

Thank you for reaching out, and I apologize for any inconvenience caused by this oversight. To better address the issue, could you kindly provide Joomla administrator access? This will enable me to thoroughly investigate the matter and provide you with a prompt resolution.

I appreciate your cooperation and will ensure to get back to you as soon as possible.

Best regards,

Toufiqur Rahman (Team Lead, Support)

0
F
Fuze1
Accepted Answer
1 year ago #165479

Thanks Ofi and Toufiq for your quick responses.

I've just added admin access to the hidden content.

Thanks

Tom

0
Toufiq
Toufiq
Accepted Answer
Senior Staff 1 year ago #165482
0
F
Fuze1
Accepted Answer
1 year ago #165514

Hi Toufiq,

I've now resolved my web server issue - For reference, I can't have force SSL enabled in Global Config as it seems Cloudflare's SSL doesn't allow this.

Please investigate the "http" logo issue.

Thanks

0
Toufiq
Toufiq
Accepted Answer
Senior Staff 1 year ago #165531

Could you please upload your logo again? I temporarily removed it for testing purposes. Thank you for your understanding.

0
F
Fuze1
Accepted Answer
1 year ago #165541

Thanks Toufiq, I've just re-uploaded my logo and that seems to have resolved it. How strange!

Thanks!

0
F
Fuze1
Accepted Answer
1 year ago #165555

Thanks Toufiq, this has worked on one of my sites which is great.

However it hasn't worked on another site (see hidden content). I've tried pasting the code above into templates/shaper_helixultimate/feature/logo.php and also re-uploaded the client's logo, but it's still not appearing unfortunately.

This is another site using a Cloudflare's SSL Certificate, so "force SSL" can't be enabled in global configuration.

Please advise.

Thanks

0
Toufiq
Toufiq
Accepted Answer
Senior Staff 1 year ago #165559

Please check now and let me know. Thanks

0
F
Fuze1
Accepted Answer
1 year ago #165560

Perfect - Many thanks Toufiq, that's resolved the issue.

What was the fix? Just in case I have the same issue with any more sites I use Cloudflare on.

Thanks

Tom

0
Toufiq
Toufiq
Accepted Answer
Senior Staff 1 year ago #165562

Already, I have shared with you the full code. You didn't use the shared code. Thanks

0