5

I have installed an SSL certificate on my site but have found that when using this image source address:

<img src="{{media url='wysiwyg/infortis/ultimo/menu/featured2.jpg'}}"

I receive an error saying that not all page content is secure.

When I change to:

<img src="https://mywebsite.com/media/wysiwyg/infortis/ultimo/menu/featured2.jpg"

Then everything works fine.

The problem is that I do not wish to deliver this image via HTTPS for nonsecure pages as I believe this may cause pages to load slower.

How can I link to the image in a way that will use Magento's secure/unsecure system correctly?

2 Answers 2

10

Your first attempt (with the {{media}} tag) is correct and should work.

In the admin go to System > Configuration > Web > Secure and make sure the following are set:

  • Base Link URL - {{secure_base_url}}
  • Base Skin URL - {{secure_base_url}}skin/
  • Base Media URL - {{secure_base_url}}media/
  • Base Javascript URL - {{secure_base_url}}js/

This way all the paths generated will follow the protocol given in "Base URL". If a page is secure everything on it will also be served secure.


Alternatively, just leave out the protocol and colon in URLs and the browser will choose the right one automatically. AFAIK this works with all browsers even when linking to external sites.

<img src="//mywebsite.com/media/wysiwyg/infortis/ultimo/menu/featured2.jpg" />

If you need to force either a secure or unsecure URL directly then there is the "config" tag instead. This should end with a forward slash because the config value should also end with a slash. Write your path immediately after this.

{{config path="web/secure/base_media_url"}}wysiwyg/infortis/ultimo/menu/featured2.jpg

If you have upgraded to Magento 1.9.2.2 or applied the latest patch then you need to whitelist the paths you use in {{config}} directives. To do so, enter them in system > permissions > variable permissions.

6
  • Great idea. I am thinking that perhaps the reason the {{media}} tag is not working is because the image is being used inside of Magento's Navigation and perhaps Magento secure/unsecure system was not meant to be used within the menu. Either way, the src="//..." method works. Thank you! Commented Oct 2, 2013 at 20:49
  • Which bit do you mean by "Magento's Navigation"? Template tags like {{..}} only work in CMS pages and blocks. Commented Oct 2, 2013 at 21:28
  • Yes my template allows cms inside magento's navigation. Commented Oct 3, 2013 at 11:26
  • This does not work if your media or skin URLs point to CDNs. I tried {{secure_base_skin_url}} with no luck. @clockworkgeek do you know how to get the actual secure base skin/media/js URL instead of taking the directory onto the base URL?
    – Tyler V.
    Commented Oct 21, 2015 at 0:45
  • 1
    @TylerV. The values which start with {{secure_ will not work in CMS because they are not CMS tags, they only have meaning in the web section of config. Search for "magento cms tags" or "magento cms directives" to see the many other choices available. I've updated my answer with a likely one, {{config}} Commented Oct 31, 2015 at 14:03
17

Use _secure attribute.

Ex:

<img src="{{media url="wysiwyg/infortis/ultimo/menu/featured2.jpg" _secure="true" }}" />
1
  • 1
    This is actually the correct answer. Commented Aug 19, 2016 at 20:42

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.