Skip to content

Instantly share code, notes, and snippets.

@Dh42
Last active January 1, 2016 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dh42/8172816 to your computer and use it in GitHub Desktop.
Save Dh42/8172816 to your computer and use it in GitHub Desktop.
Override for Prestashop 1.5 Tools.php to make media servers not need SSL check http://blog.dh42.com/prestashop-media-server-hack/ for more information and use case.
<?php
class Tools extends ToolsCore
{
public static function getMediaServer($filename)
{
if (self::$_cache_nb_media_servers === null)
{
if (_MEDIA_SERVER_1_ == '')
self::$_cache_nb_media_servers = 0;
elseif (_MEDIA_SERVER_2_ == '')
self::$_cache_nb_media_servers = 1;
elseif (_MEDIA_SERVER_3_ == '')
self::$_cache_nb_media_servers = 2;
else
self::$_cache_nb_media_servers = 3;
}
if (self::$_cache_nb_media_servers && Tools::usingSecureMode() == false && ($id_media_server = (abs(crc32($filename)) % self::$_cache_nb_media_servers + 1)))
return constant('_MEDIA_SERVER_'.$id_media_server.'_');
return Tools::usingSecureMode() ? Tools::getShopDomainSSL() : Tools::getShopDomain();
}
}
@ReflexivR
Copy link

Hi there, thanks for posting this! It works great except for when you add to cart. With ajax cart enabled, it tries to load the product image over HTTPS (used in the animation of the image going to the cart). Any idea how to fix?

@mmariusz
Copy link

HI, I have the same problem... Have you got any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment