Matthew Dolman
Matthew Dolman

Reputation: 1800

Magento SSL Friendly getImageUrl();

I have built a mega dropdown menu for my store which includes subcategory images. However when I enter to the secure part of the site I get SSL errors because the images in the menu are being loaded via http rather than https

The image tag in my template file looks like this

<img src="<?php echo $subCategory->getImageUrl(); ?>" />

Is there a way to make it so that the images are returned with the https url when in the secure part of the site?

Upvotes: 1

Views: 1390

Answers (3)

Johnny86
Johnny86

Reputation: 67

str_replace(array("http://","//") That would solve your issue.

Upvotes: 1

loeffel
loeffel

Reputation: 485

But this way the image is always fetched via https - that's not a realy solution either. For example my entire page will load in half the time it takes one image to be fetched via https.

Upvotes: 0

benmarks
benmarks

Reputation: 23205

Try disabling the blocks_html cache in the backend and see if that makes a difference.

If it does, there are several options:

  1. Leave blocks_html cache off (yuk!)
  2. Add secure/nonsecure to Navigation block cache key (fun, but some work)
  3. Echo the path out with a relative protocol, e.g. src="//site.com/media/catalog/category/subcat.jpg"

HTH Ben

Upvotes: 1

Related Questions