Web Development

Magento : Get Skin and Media URLs

In this article we will see; in Magento how we can get Skin, Media and Other URLs in Static block and .phtml file.

In one of the earlier article we have seen 4 ways to get Magento Homepage URL. Now in this article we will see how to get Skin, Media URL in .phtml file and static block.

So Let’s start with the Static block first:

Get Media URL in Static Block – Magento

[cc lang=”html”]
{{media url=”}}
[/cc]

If you want to get something added after media URL then you just need to place below code instead.

[cc lang=”html”]
{{media url=’images/logo.jpg’}}
[/cc]

Get Skin URL in Static Block – Magento

[cc lang=”html”]
{{skin url=’images/sampleimage.jpg ‘}}
[/cc]

If you want to get something added after skin URL then you just need to place below code instead.

[cc lang=”html”]
{{skin url=’images/logo.jpg’}}
[/cc]

Get Homepage URL in Static Block – Magento

[cc lang=”html”]

{{config path=”web/unsecure/base_url”}}


{{config path=”web/secure/base_url”}}

[/cc]

Get Skin URL in .phtml File – Magento

[cc lang=”php”]
// Non Secure URL
echo $this->getSkinUrl(”);

// Secure URL
echo $this->getSkinUrl(”, array(‘_secure’=>true));

// If you want something added behind the URL
echo $this->getSkinUrl(‘image.jpg’);
[/cc]

Get Media URL in .phtml File – Magento

[cc lang=”php”]
echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
[/cc]

Stay tuned with us on Twitter, Facebook and Email for more tips and tricks for magento.

Shares:
  • MM
    MM
    August 8, 2012 at 12:24 am

    helps a lot, thx…..

    Reply
  • MM
    MM
    December 20, 2019 at 2:53 pm

    helps a lot, thx…..

    Reply
  • Wahlers
    Wahlers
    January 10, 2013 at 12:48 pm

    Magnificent goods from you, man. I’ve be mindful your stuff prior to and you are just too great. I actually like what you have received here, certainly like what you’re saying and the way through which you assert it. You are making it enjoyable and you still take care of to stay it sensible. I can not wait to read much more from you. This is actually a terrific website.

    Reply
  • Wahlers
    Wahlers
    December 20, 2019 at 2:55 pm

    Magnificent goods from you, man. I’ve be mindful your stuff prior to and you are just too great. I actually like what you have received here, certainly like what you’re saying and the way through which you assert it. You are making it enjoyable and you still take care of to stay it sensible. I can not wait to read much more from you. This is actually a terrific website.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *