ryanmetzler3 Posted December 15, 2013 Share Posted December 15, 2013 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> Quote Link to comment Share on other sites More sharing options...
scootstah Posted December 16, 2013 Share Posted December 16, 2013 What do you see when you inspect the element? Quote Link to comment Share on other sites More sharing options...
ryanmetzler3 Posted December 16, 2013 Author Share Posted December 16, 2013 What do you see when you inspect the element? Im getting an error in the console that says this: Failed to load resource: the server responded with a status of 404 (Not Found). Then it gives me this link, http://i1.wp.com/localhost/img/default_avatar.gif, but it just opens to a 404 not found. Quote Link to comment Share on other sites More sharing options...
scootstah Posted December 16, 2013 Share Posted December 16, 2013 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? Quote Link to comment Share on other sites More sharing options...
ryanmetzler3 Posted December 16, 2013 Author Share Posted December 16, 2013 (edited) 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 December 16, 2013 by ryanmetzler3 Quote Link to comment Share on other sites More sharing options...
Solution scootstah Posted December 16, 2013 Solution Share Posted December 16, 2013 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. Quote Link to comment Share on other sites More sharing options...
ryanmetzler3 Posted December 16, 2013 Author Share Posted December 16, 2013 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.