1

I have developed a module to make a custom menu to show thumpnail images of sub categories when hover the main menu or category.

For that in the Block of my module, I return the src of each thumpnail images using the following.

return Mage::getBaseUrl('media').$thumnail

As it returns the url scheme as http always, checkout page is not completely secure. So I changed it to return secure url as below

return Mage::getBaseUrl('media',true).$thumnail 

Then it returns always https in it's url scheme.

I want https, only for checkout page since it needs to be secure, and http for other pages. How to solve it?

2 Answers 2

1

Just change Mage::getBaseUrl('media',true); to

$this->getBaseMediaUrl();

$this->getBaseMediaUrl().$thumnail; 
2
  • Thanks for the reply! It returns url scheme always as 'https'.
    – SIBHI S
    Commented Sep 23, 2014 at 5:05
  • I want https, only for checkout page, not for other pages. Your solution returns https for all pages (As Mage::getBaseUrl('media',true) doing)
    – SIBHI S
    Commented Sep 23, 2014 at 6:10
1

Either not passing the second parameter or passing it as null should work here for you. When it builds the url if the secure parameter is null then if checks if you are currently on a secure page.

$secure = is_null($secure) ? $this->isCurrentlySecure() : (bool)$secure;

This then goes off and checks if you are requesting the page from http or https. Once this has been returned Magento then loads the url from the config from either the secure or unsecure node.

$url = $this->getConfig('web/' . ($secure ? 'secure' : 'unsecure') . '/base_url');

If you step through the functions you should be able to find the error but the function call should be return Mage::getBaseUrl('media').$thumnail

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.