Magento SSL Friendly getImageUrl(); - magento

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?

Try disabling the blocks_html cache in the backend and see if that makes a difference.
If it does, there are several options:
Leave blocks_html cache off (yuk!)
Add secure/nonsecure to Navigation block cache key (fun, but some work)
Echo the path out with a relative protocol, e.g. src="//site.com/media/catalog/category/subcat.jpg"
HTH
Ben

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

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.

Related

Getting URL with javascript

Because of an HTTP_REFERER issue I need to make a url pass from an https site to http.
I have this bit of javascript but it is not working.
Save this page as PDF
Can I also find out how I would append the current site using javascript their api url?
http://api.htm2pdf.co.uk/urltopdf?apikey=yourapikey&url=http://www.example.com
Any advice?
Need to block the initial anchor tag event.
Save this page as PDF
I would use either javascript or the href attribute, not both. I don't see how they would work well together.
You can use .preventDefault() as noted, but why put the href attribute there in the first place?
Is this what you're looking for? It should work on both http or https sites.
<a onclick="window.open('http://api.htm2pdf.co.uk/urltopdf?apikey=yourapikey&url=' + window.location.href, '_blank', 'location=yes,scrollbars=yes,status=yes');">Save as PDF</a>

Ajax generated pages with different URLs

I couldn't really word the title very well, but here's my problem: I've got a webpage that reads from a database each time the user clicks a button, the content is then replaced for part of the page.
Because it is an ajax load, everything is done in the background, and so the URL stays the same. This wasn't be a problem at all until I realised that I will want to have a different Facebook comments box for each set of content that is loaded - so if someone comments, it is posted to their facebook profile, people click on the link and are then taken to different content.
So... what I need is some way of referencing each set of content, and I've found a site that does exactly that (I'm sure there are a lot of them).
Here's the link.
Each set of content has a different 'hash code' (because I don't know the actual name for it) which is appended to the URL - in this case the code is "#1922934", this allows people to post links to it that specific set of content on Facebook etc. - and also allows a different Facebook comment box for each set of content.
Does anyone know how such a set-up can be achieved or how these 'hash codes' work?
Here's a document from wikipedia on it.
[http://en.wikipedia.org/wiki/Fragment_identifier][1]
The main idea is that URI fragments are used because they don't cause a page reload. They also can be used to refer to anchors on a web page.
What I would do is on page load use JavaScript to read the URI fragment (location.hash) then make a request to your server to load the comments etc. The URI fragment cannot be read by a server and is only found through a client (browser)
Sounds like you want something like SammyJS.

Page tab loads content from some domains but not others?

I’ve created a welcome tab for a Page. When I set the Page Tab URL to pull content from http://journalism.unr.edu/facebook/welcome/, the tab comes up blank. But when I uploaded a copy of the content to a free 000webhost.com hosting account at http://rsj.netii.net/welcome/, and used that address as the Page Tab URL, the content loads just fine. What I want to know is, why?
I’ve experimented with pulling content from other URLs into my page tab:
yahoo.com - works
google.com - doesn’t work
unr.edu - works
journalism.unr.edu - doesn’t work
unr.edu/engineering - doesn’t work (shows error message: “The page cannot be displayed. The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt access.”)
Does anyone know why page tabs/iframe apps load content from some domains but not others? Can anyone tell me how to fix the journalism.unr.edu web server (I have access to it, I work for the journalism school) so that page tabs can load content from it? We’d like to be able to pull content straight from our website without having to copy it over to a free hosting account.
I'm not sure what is the problem with http://journalism.unr.edu/facebook/welcome/
But I cannot even get it to load inside of an iframe. Maybe there's some restriction setup in the hosting or server that servers that site. Or maybe a more complex issue with the server not allowing it to be iframed from a different host domain.
Simple to test, just make an html page like.
<html>
<body>
<p>I hope it loads</p>
<iframe src="http://journalism.unr.edu/facebook/welcome/" width="400" height="300"></iframe>
</body>
</html>
Also: "unr.edu/engineering - doesn’t work (shows error message: “The page cannot be displayed. The page you are looking for cannot be displayed because an invalid method (HTTP verb) was used to attempt access.”)"
That one is because you're pointing to a resource on the server that does not allow HTTP POSTs.

plain http image on https/ssl page = warning

I've found the page that plain http images with a https/ssl page can't be displayed without warnings. Are there any way to display a picture from another http:// web-site on your https://web-site without warnings? (suppose you have a permission to display that picture on you web-site).
Chrome put a yellow triangle on SSL locker: "...However, this page includes other resources, that are not secure..."
IE displays a warning when a page loads: "Do you want to view only the webpage content that was delivered securely?"
So, how to display a picture on https:// page if it is on another web-server?
You can use the information on this article on Encosia. Basically you have to use a // syntax for your urls in order to use the same protocol in all cases. For example, if you have a https request, the following
//ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js
will hit google's CDN using the https protocol. However, if you don't have control over the other server, i think you're out of luck. If you do have control over the other server i'd recommend using the method described in the article above by allowing your content server to serve both protocols.

Internet Explorer does not load images cross domain (https)

this is an updated question:
I am trying to include a picture on an external server.
PROBLEM HERE: my home website is using https:// and the picture on the external server is just http. The picture is fine (tested) but IE seems not to allow to access http:// sources when on a https:// website.
I am looking for html or javascript code to allow access for loading pictures from other domain WHEN my home domain is HTTPS and my external domain is HTTP
thanks
Klaus
I'm afraid this is a feature of the browser. When you enter a page like this on IE and some other browsers, it will give the user the option to disallow "unsecured" elements on the page (this includes elements served over HTTP); and will not display them. Your page cannot override the users' action.

Resources