How do I show the image instead of the url?
echo "<b>Image: </b> http://graph.facebook.com/" . $posts['from']['id'] ."/picture?type=large</br>";
Simply use the <img> tag with src set to your url:
echo "<b>Image: </b> <img src='http://graph.facebook.com/"
. $posts['from']['id'] ."/picture?type=large'></br>";
try:
echo "<b>Image: </b><img src='http://graph.facebook.com/" . $posts['from']['id'] ."/picture?type=large'/></br>";
<img src="http://graph.facebook.com/".$posts['from']['id']
."/picture?type=large">
This will build the correct tag.
echo '<b>Image: </b> <img src="http://graph.facebook.com/' . $posts['from']['id'] . '/picture?type=large" /><br />';
Alternatively, without using concatenation:
<b>Image: </b> <img src="http://graph.facebook.com/<?php echo $posts['from']['id']; ?>/picture?type=large" /><br />
Or using short tags:
<b>Image: </b> <img src="http://graph.facebook.com/<?=$posts['from']['id']?>/picture?type=large" /><br />
Related
i am having a issue on my osclass theme. I want to display a particular image from my folder manually. The images are in the folder and i am using this function to display the image, could someone help.
if(!function_exists('aiclassy_draw_ad')) {
function aiclassy_draw_ad(){
echo '<div class="advertise_area">
I want my image to be called here
</div>';
echo ' <br /> <div class="advertise_area">
</div>';
echo ' <br /> <div class="advertise_area">
</div>';
echo ' <br /> <div class="advertise_area">
</div>';
}
}
Is it what you need?
echo '<div class="advertise_area">
<img src="http://morelook.com/content/uploads/2011/07/advertise_here_250x250.png" alt="" />
</div>';
EDIT
Based on OP comment: JSFIDDLE
Turn off your adblocker if you have.
You should place an image tag in your div tag, like this:
if(!function_exists('aiclassy_draw_ad')) {
function aiclassy_draw_ad(){
echo '<div class="advertise_area"><img src="image.jpg" alt="" /></div>';
echo ' <br /> <div class="advertise_area">
</div>';
echo ' <br /> <div class="advertise_area">
</div>';
echo ' <br /> <div class="advertise_area">
</div>';
}
}
I have a code here that outputs a image link like http://img.domain.com/2515.jpg
<?php echo IMG_URL . $code . ".jpg" ?>
But i want to make it print this entire thing <img src="http://img.domain.com/2515.jpg" alt="" title="Created by domain.com" />
How can i format that php string <?php echo IMG_URL . $code . ".jpg" ?>
to include that entire img src link?
I am trying to fit it in this html code below
<li><a class="linkInsert" data-value="<?php echo IMG_URL . $code . ".jpg" ?>">Direct Link (email & IM)</a></li>
Update:
i figured it out below with just using '
<li><a class="linkInsert" data-value='<img src="<?php echo IMG_URL . $code ?>.jpg" alt="">'>HTML Image (websites / blogs)</a></li>
Try this,
<?php echo '<img src="'.IMG_URL.$code.'.jpg" alt="" title="Created by domain.com" />' ;?>
You just have to use single quotes and double quotes alternatively.
PHP can be embedded inside HTML:
<img src="<?php echo IMG_URL . $code ?>.jpg" alt="">
This question already has answers here:
How to extract img src, title and alt from html using php? [duplicate]
(10 answers)
Closed 9 years ago.
How can I use img tag in php code?:
This is the code I have so far:
$message = $message."...<br />".$lang->messagemore."";
And I wish to use an image instead of ".$lang->messagemore." but I don't know how to use img tag in php :|
I have tried googling but I only find some tag info from html but not php code.
<img src="/res/gif/bullet_info_sq.gif" alt="" />
But I wish to use that in php so I could use your help.
Thank you very much!
tl;dr
Replace: $lang->messagemore
With: <img src="/res/gif/bullet_info_sq.gif" alt="" />
When you replace your PHP variable with the img tag, the HTML must still remain within the quotes of the PHP string, and thus the actual quotes for your img tag must be escaped, just as you've done for your a tag. You may also opt to use single quotes, to avoid having to escape. This should result any one of the following equivalent code snippets (I've added whitespace for readability):
Double quotes (with escaping):
$message = $message . "...<br />
<a href=\"" . $mybb->settings['bburl'] . "/" . $announcement['threadlink'] . "\">
<img src=\"/res/gif/bullet_info_sq.gif\" alt=\"\" />
</a>";
Single quotes for HTML attributes:
$message = $message . "...<br />
<a href='" . $mybb->settings['bburl'] . "/" . $announcement['threadlink'] . "'>
<img src='/res/gif/bullet_info_sq.gif' alt='' />
</a>";
Single quotes for PHP string:
$message = $message . '...<br />
<a href="' . $mybb->settings['bburl'] . '/' . $announcement['threadlink'] . '">
<img src="/res/gif/bullet_info_sq.gif" alt="" />
</a>';
Just echo the HTML code ( in your case , the <img> tag ) in PHP , just like you did for <a> tag.
You can use like this,
$message = $message."...<br /><img src='/res/gif/bullet_info_sq.gif' alt='' />";
use this:
$message = $message."...<br />".'<img src="/res/gif/bullet_info_sq.gif" alt="" />'."";
Use this
$message = $message."...<br /><img src=\"/res/gif/bullet_info_sq.gif\" alt=\"\" />";
It works like that:
$message = $message."...<br />"."<img src='".$aImageURL."' alt="" />";
Simply replace de img src with a PHP variable. ($aImageURL will be the URI of the image)
Take a look at the quotes (I put simply quotes in the src attribute, you can do that)
So simple, do not create mess with double quotes " PHP optimally used single quotes '. Use standard html within string!
echo ' <img src="php.gif" /> ';
I have a string, an img url, in a php block called $str. And I want to set that string as the img src in an img src but its not working.
<img src="<?php $str ?>" height="50px" width="50px">
how else can i set the src to the $str string?
<img src="<?php echo $str;?>" height="50px" width="50px">
Well, I found correct answer for this problem. Nothing works well from above answers, that codes only print out source string to html page on site.
This works for me (I have my function that return source string of picture):
require_once("../../my_coded_php_functions.php");
<?php echo '<img src="' . getSourcePathOfImage() . '" />' ?>
This site(article) helped me to find and understand solution:
http://php.net/manual/en/faq.html.php
<?php echo '<img src="'.$str.'" height="50px" width="50px">' ?>
Other ways, although is not recommended. You may try :
<img src="<?=$str?>" height="50px" width="50px">
this will work, only if (in php.ini)
short_open_tag = On
I am trying to set size of an image in PHP but it's not working..
echo "<img src=".$media."width=200 height=200";
$media is the src link. Without the width and height attributes, it works perfectly well. I think that 200 must be enclosed in double quotations but I am unable to do that. Any ideas on how to solve this problem?
width is currently concatenated with your file name. Use:
echo '<img src="'.$media.'" width="200" height="200" />';
The /> closing tag is necessary to correctly render your image element.
The quotes around tag names are recommended. Omitting these quotes will only cause issues when:
The attribute value contain spaces, or
You forgot to add a space after the attribute value
Yet another alternative, just for kicks:
echo <<<EOL
<img src="{$media}" width="200" height="200" />
EOL;
aka a HEREDOC.
That is because that is not proper HTML.
In your code you'd get something like:
<img src=image.jpgwidth=200 height=200
And what you need is:
<img src="image.jpg" width="200" height="200" />
So do:
echo '<img src="' . $media . '" width="200" height="200" />';
echo '<img src="' . $media . '" width="200" height="200" />';
You should be able to make it work with the following code
echo "<img src=\"".$media."\" width=200 height=200>";