troubleshooting Question

Php snippet pulling in full url. I just want relative url

Avatar of Rowby Goren
Rowby GorenFlag for United States of America asked on
PHP
7 Comments2 Solutions288 ViewsLast Modified:
Hello PHP experts,

I am trying to troubleshoot an image link issue.   I have sent an email to the developer and he will eventually get back to me.  But maybe not quickly.

In the meantime I think I have found the root of the issue.

There is some js in the application that is referencing the various images.  But instead of just putting in the relative url it is pulling in the full absolute url.  I want the relative url, not the absolute url.

I know next to nothing about php, but I found this snippet in some javascript in his application.

image_markup: '<img id="fullResImage" src="{path}" />',
I am thinking that "{path}" is built-in php placeholder code for full url.  Perhaps there is some other placeholder other than  "{path}" that will give me just the relative path.

However, as I write this question, I just found another snippet.  This is a php snippet.  And I am thinking that maybe it is controlling the display of the url.  Here it is:
if(strstr($element_setting['image'],"http://")){
	$image_url=$element_setting['image'];
}
else{
	$image_url="../".$element_setting['image'];
}
?>
<h5><?php echo $element_attribute['name'];?></h5>
<div style="max-width:300px;"><img src="<?php echo $image_url;?>"/></div>
As I look at the above snippet I am thinking that it is more likely the absolute url culprit.

Nevertheless, what the current code is giving me (and I don't want) is <img alt="" src="http://www.domainname.com/images/EmployeePhotos/martha.jpg" /></p>

What I want is a relative path, such as <img alt="" src="/images/EmployeePhotos/martha.jpg" /></p>

I thought while I wait for the developer to reply I would ask your thoughts here.  Of course I have a backup of the files.  I thought maybe you can reply quicker than the developer.  After all, this is a holiday weekend, isn't it?

I realize this question may be an exercise in futility without the full code from the application, but I am hoping that the snippets of code may offer a clue to a solution from the EE php experts. :)

Thanks!

Rowby
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros