Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9194919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:31:32+00:00 2026-06-17T21:31:32+00:00

I am able to get the web path to the file like so: $filename

  • 0

I am able to get the web path to the file like so:

$filename = 'elephant.jpg';
$path_to_file = $this->getSkinUrl('manufacturertab');
$full_path = $path_to_file . '/' . $filename;

But if the file doesn’t exist, then I end up with a broken image link.

I tried this:

if(!file_exists($full_path)) {
  Mage::log('File doesn\'t exist.');
} else {
  ?><img src="<?php echo $full_path ?>" /><?php
}

Of course that didn’t work because file_exists does not work on urls.

How do I solve this?

1.)
Can I translate between system paths and web urls in Magento?

e.g. something like (pseudocode):

$system_path = $this->getSystemPath('manufacturertab');

That looks symmetrical and portable.

or
2.)
Is there some PHP or Magento function for checking remote resource existence? But that seems a waste, since the resource is really local. It would be stupid for PHP to use an http method to check a local file, wouldn’t it be?

Solution I am currently using:

$system_path = Mage::getBaseDir('skin') . '/frontend/default/mytheme/manufacturertab'; // portable, but not pretty
$file_path = $system_path . '/' . $filename;

I then check if file_exists and if it does, I display the img. But I don’t like the asymmetry between having to hard-code part of the path for the system path, and using a method for the url path. It would be nice to have a method for both.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:31:33+00:00Added an answer on June 17, 2026 at 9:31 pm

    Function

    $localPath = Mage::getSingleton( 'core/design_package' )->getFilename( 'manufacturertab/' . $filename, array( '_type' => 'skin', '_default' => false ) );
    

    will return the same path as

    $urlPath = $this->getSkinUrl( 'manufacturertab/' . $filename );
    

    but on your local file system. You can omit the ‘_default’ => false parameter and it will stil work (I left it there just because getSkinUrl also sets it internaly).

    Note that the parameter for getSkinUrl and getFilename can be either a file or a directory but you should always use the entire path (with file name) so that the fallback mechanism will work correctly.

    Consider the situation

    skin/default/default/manufacturertab/a.jpg

    skin/yourtheme/default/manufacturertab/b.jpg

    In this case the call to getSkinUrl or getFilename would return the path to a.jpg and b.jpg in both cases if file name is provided as a parameter but for your case where you only set the folder name it would return skin/yourtheme/default/manufacturertab/ for both cases and when you would attach the file name and check for a.jpg the check would fail. That’s why you shold always provide the entire path as the parameter.

    You will still have to use your own function to check if the file exists as getFilename function returns default path if file doesn’t exist (returns skin/default/default/manufacturertab/foo.jpg if manufacturertab/foo.jpg doesn’t exist).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm not able to get this persistence file correct... I do not find any
not able to get this, can someone help for this LINQ query? select col1,
I am able to get the current date, but I don't know how to
I'm able to get the following results with this working query: $query = SELECT
In a web application I'm working on, we'd like to be able to show
I am not able to get the hg head or status for a given
I am able to get the output of a pdf using fpdf, the problem
I am able to get the current page's url in jsf from back-end bean
I'm finally able to get an Access Token, now I'm very confused as how
I am not able to get my jwysiwyg and Jhtmlarea text editors to work

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.