Jump to content

broken image still showing over correct image


ryanmetzler3
Go to solution Solved by scootstah,

Recommended Posts

For some reason there is a little broken image icon is showing over an image that is displaying correctly. Here is the code that displays the image.

 

The image is showing like it should, but it has the broken link in the upper left of the image. I can't figure it out for the life of me.

$url = 'http://'.dirname($_SERVER['SERVER_NAME'].$_SERVER["REQUEST_URI"]).'/img/default_avatar.gif';
		
		return '
		
			<div class="comment">
				<div class="avatar">
					'.$link_open.'
					<img src="http://www.gravatar.com/avatar/'.md5($d['email']).'?size=50&default='.urlencode($url).'" />
					'.$link_close.'
				</div>
Link to comment
Share on other sites

But what happens when you look at the HTML source for that <img /> element? Do you see two <img />'s?

 

As for the 404, I'm not really seeing how it would be requesting that image from the code you've provided. Are you requesting that image somewhere else?

Sorry about that, when I inspect the element I just get this: 

 

<img src="http://www.gravatar.com/avatar/9f86dcad75dd12bdb549567d4c13e59e?size=50&default=http%3A%2F%2Flocalhost%2Fimg%2Fdefault_avatar.gif">

 

There is only one of them. This is actually source code that I downloaded so I am working backward. Basically when you leave a comment you fill in your name and email. I believe your avatar that shows up could be changed based on the email you supplied and if you have a gravatar account. When a user registers for my site they have the option to upload a photo, so I just want to have a default for now and this gravatar BS is confusing.  

 

Here is all the source code: 

http://tutorialzine.com/2010/06/simple-ajax-commenting-system/

Edited by ryanmetzler3
Link to comment
Share on other sites

  • Solution

If I'm understanding it correctly, you just need to have a valid URL to a default image.

 

$url = 'http://'.dirname($_SERVER['SERVER_NAME'].$_SERVER["REQUEST_URI"]).'/img/default_avatar.gif';
This link returns a 404. So if you just change this line to a valid image URL, you should be okay.
Link to comment
Share on other sites

If I'm understanding it correctly, you just need to have a valid URL to a default image.

 

$url = 'http://'.dirname($_SERVER['SERVER_NAME'].$_SERVER["REQUEST_URI"]).'/img/default_avatar.gif';
This link returns a 404. So if you just change this line to a valid image URL, you should be okay.

 

 

That is exactly what I thought. That is a valid url though, that is what is driving me nutty. I have checked it 10 times and I swear there is nothing wrong with that line. There is a folder called "img" with an image called 'default_avatar.gif' inside. I actually got it working by just setting the $url=' ';

 

So essentially I set $url equal to nothing and it works fine with the default image. That is good enough for now. There is lots of other things I need to add to this code  Later I will replace $url with a mysql query and while loop that will pull a user image from a DB and hopefully I can get that working when I have a clearer mind. 

 

Thanks for the help mate

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.