1

I am trying to call images in this function, but they all come up as question marks. Could anyone tell me what I did wrong?

if(!$currentvotes) $currentvotes = 0;
echo '<div class="vote vote'.$id.'"><span>'.$currentvotes.'</span>';
if($user_ID && !$alreadyVoted) echo '<br /><a post="'.$id.'" user="'.$user_ID.'"><img src="/images/thumbsup.png" WIDTH=25 HEIGHT=25></a>';
if($user_ID && $alreadyVoted) echo '<br /><span class="voted"><img src="/images/thumbsup.png" WIDTH=25 HEIGHT=25></span>';
echo '</div>';
if(!$user_ID) echo '<div class="signup"><p><a style="color:#4ec1f3;" href="'.get_bloginfo('url').'/wp-login.php?action=register"><img src="/images/thumbsup.png" WIDTH=25 HEIGHT=25></p></div>';
} 
3
  • You can't 'call' an image. You can call functions, methods, procedures, code but images are data and can't be 'called'. Commented Jun 6, 2013 at 0:18
  • i believe thats the browsers way of saying that the images are not where your html says they are Commented Jun 6, 2013 at 0:19
  • I suppose the path you are using has to be absolute eg (http://.../images/...). Or use base tag in your head in html <base href="yourdomain" target="_blank"> Commented Jun 6, 2013 at 0:29

3 Answers 3

1

I am trying to call images in this function

As in the comments:

You can't 'call' an image. You can call functions, methods, procedures, code but images are data and can't be 'called'. – Patashu


[...] they all come up as question marks

Right click on those question marks: choose "open image in new window". You should see a new page with a 404 error. Look at the link of that page: that's the path where your image is supposed to be (if you're getting a 404 error it simply means they are not there). Create the folder images and upload the file thumbsup.png. Now reload the page.

Sign up to request clarification or add additional context in comments.

3 Comments

This place is awesome. You were right. The path to the image was wrong. Thanks so much man! Dumb mistake!
if this question solved the issue, would you mind mark it as correct? Thanks.
Yup! As soon as I figure out how haha
1

I suppose the path you are using has to be absolute eg (http://.../images/myimage.jpg) instead /images/myimage.jpg. This is common issue when you write custom code (don't use standard framework) and use .htaccess to rewrite urls.

You can set basepath as constant so you can easy change it if you switch domains.

define("BASE_PATH", "http://mydomain.com");

and then in code use it:

BASE_PATH."/images/myimage.jpg"

Or use base tag in your head in html

<base href="http://www.yourdomain" target="_blank">

And as Saturnix said in his answer you should have folder named "images" and filename you put in src.

4 Comments

img src doesn't necessarily need absolute path. OP's just ignoring, probably, the correct path to the image file.
I had issues like this, and absolute path was the resolution
absolute path is not a good solution: the day you'll switch domain you'll have to reconfigure all of your pages.
I agree, but i gave second resolution with setting base path
1

If an image can't be found in the location you specify in your HTML, the browser will display a broken image link marker, maybe like one of these;

  • Chrome enter image description here

  • IE10 enter image description here

  • Firefox 10 enter image description here

Each browser has its own marker. Maybe your browser uses a question mark to indicate a broken image link.

2 Comments

No problem! And take no notice of the people who downvote questions initially. You asked a perfectly reasonable question. What browser are you using?
I'm using Safari mostly, but I also check everything in Chrome, Opera, Firefox and Internet Explorer to be sure :P

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.