I'm trying to get a function working to re size any image using a custom module and helper class. For the record I'm running this on a local XAMPP server.

If I pass a image url and a destination url using '/' all works fine. However I need to implement this with DS for future proofing. The following is an example line of code I'm using. with the DS instead of '/'

$newPath = Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) . DS . "resized" . DS . $fileName;

This returns (without the http or localhost at the start because stackoverflow doesn't allow that even in code) "/test/media/resized\catalog\category\testcat.jpg"

How do I make it so that DS correctly returns forward slashes?

  • DS is directory separator. You should use it to build path to file. You shouldn't use it to build image URL. Mar 7, 2013 at 12:28
  • @Zyava - The OP is using Mage::getBaseDir - not getSkinUrl - he is looking to get the path to image - not the URL for the image Mar 7, 2013 at 12:29
  • I would say, the error is in the database and the dump is from windows. Mar 7, 2013 at 12:52
  • I am confused. It looks like the OP wants to say that the line returns http://localhost/test/media/resized\catalog\category\testcat.jpg but he had problems to write that on stackexchange??? But getBaseDir does not add a http:// ...
    – Alex
    May 11, 2013 at 22:28

2 Answers 2


There should be no reason at all to change the DS.

DIRECTORY_SEPARATOR is a predefined PHP constant that is set by your PHP installation itself.

If it is returning the wrong value, it is because your PHP installation is wrong.

Don't adjust Magento to suit a broken PHP install.


This is strictly speaking correct for Windows systems. You probably have to set DS hardcoded, in app/Mage.php change



define('DS', '/');

Your Answer

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

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