I'm trying to get this so when I click the image, the image then shows in a new tab so it's able to be saved
I've tried adding the a href tags inside and around.
Code:
echo "<img src=" . random_image('css/avatars') . " />";
This is what you want:
echo '<img src="' . random_image('css/avatars') . '" />';
You should try
echo "<a target='_blank' href='".random_image('css/avatars')."'>"."<img src=" . random_image('css/avatars') . " /></a>";
I think this can help you
The problem is that you are not properly concatenating your string with what you get from random_image function.
You can try following code, here I am assuming that your random_image function returns complete path to your image
function random_image($path)
{
// returning dummmy image
return "https://images.unsplash.com/photo-1535498730771-e735b998cd64?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=623ed05afcc5a3fa1e444ffca95854dc&w=1000&q=80";
}
echo "<a href='".random_image('css/avatars')."' target='_blank'> <img src='".random_image('css/avatars')."' /></a>";
Related
I have an image displayed in the following manner:
<img src="<?php bloginfo('template_directory')?>/images/logo/logo.png">
Now, however, I want to create a shortcode that has an attribute and uses that same image inside it. So I tried the following:
add_shortcode('scrollTop', function(){
echo "<a href='#content' class='content'>";
echo "<img src='bloginfo('"template_directory"')/images/logo/logo.png'">;
echo "skipping content";
echo "</a>";
});
Its a syntax error I assume, but am struggling to find a way around.
How can I add the image inside the shortcode?
Use the concatenation operator and correct single quotes inside the bloginfo function.
add_shortcode('scrollTop', function(){
echo "<a href='#content' class='content'>";
echo "<img src='" . bloginfo('template_directory') . "/images/logo/logo.png'>";
echo "skipping content";
echo "</a>";
});
Also make sure to not use echo inside your shortcode to display something. Use return instead. See this question for more information.
add_shortcode('scrollTop', function(){
return "<a href='#content' class='content'>
<img src='" . bloginfo('template_directory') . "/images/logo/logo.png'>
skipping content
</a>";
});
I know this has already been put out on here but I've looked and mine still won't work and I don't know why someone please give me a hand.
echo '<img src="' . Mage::helper('catalog/image')->init($_product, 'small_image')->resize(50,50); . '"/>';
Remove the semicolon you have after resize
echo '<img src="' . Mage::helper('catalog/image')->init($_product, 'small_image')->resize(50,50) . '"/>';
Try this
echo "<img src= '".Mage::helper('catalog/image')->init($_product, 'small_image')->resize(50,50)."'/>";
Please change
echo '<img src="' . Mage::helper('catalog/image')->init($_product, 'small_image')->resize(50,50); . '"/>';
this line to
echo '<img src="' . Mage::helper('catalog/image')->init($_product, 'small_image')->resize(50,50) . '"/>';
Because you had put one extra semi column ; after the resize(50,50)
Please change your code and try. Definitely work .
I have been trying to echo images from my database using PHP. I have tried various solutions on the forum with no success. I am just getting a blank image as an output.
while($rows=mysqli_fetch_assoc($getquery))
{
$id=$rows['id'];
$LastName=$rows['LastName'];
$FirstName=$rows['FirstName'];
$Year=$rows['Year'];
$Press=$rows['Press'];
$Description=$rows['Description'];
$Title=$rows['Title'];
$image=$rows['image'];
echo '<div class = "paragraph">' . $LastName . '<br/>'. $FirstName . '<br/>' . $Year . '<br/>' . $Press . '<br/>' . $Title . '<br/>'. $Description . "<img src='image/".$row['image']."' />" . '</div>' ;
}
You're echoing the image as $row['image'], but the only prior references to the image are $rows['image'] (note the s) and $image. Update the echo statement to use either of these and not $row['image'].
Edit: This will not fully fix your issue. As noted in a comment to your question, you will need to do some finagling to actually display the image as demonstrated here.
while($rows=mysqli_fetch_assoc($getquery)){
$id=$rows['id'];
/*
assuming the `image` directory is relative to the root
and not the directory from which the script runs then
a leading slash might be the issue.
*/
echo "
<div id='{$id}' class='paragraph'>
{$rows['LastName']}<br/>
{$rows['FirstName']}<br/>
{$rows['Year']}<br/>
{$rows['Press']}<br/>
{$rows['Title']}<br/>
{$rows['Description']}
<!--<img src='/image/{$row['image']}' />-->
<img src='data:image/jpeg;base64, {$rows['image']}' alt='' title='' />
</div>";
}
If you store the mimetype of the image when you save it to the db then you would substitute the proper mime/content type in above ~ ie: image/png, image/gif etc so that might then become something like:
<img src='data:{$rows['mimetype']};base64, {$rows['image']}' alt='' title='' />
My code in php is
echo $preference[0]."</br>";
echo '<p class="filter_entity">'.$preference[0].'<img src="' . base_url() . 'images/close-icon.png" onClick="filter_close()"></p>';
html out put is
Business
<img onclick="filter_close()" src="http://localhost/AEC/images/close-icon.png">
I want to put $preference[0] in filter_close() of my php code ... dont know how to do it .
Something like this?
$param = $preference[0];
echo '<p class="filter_entity">'.$preference[0].'<img src="' . base_url() . 'images/close-icon.png" onClick="filter_close(\''.echo $param.'\')"></p>';
Just append the variable as a parameter of the js function
http://php.net/manual/en/language.types.string.php#language.types.string.syntax.double
echo "Some array item: {$array[0]}";
can anyone tell my why this:
echo "<a href='productdetail.php?product=" . $rij['productnaam'] . "'><img src='../images/producten/monster_energy_green.png' alt='' /></a>";
does give a clickable image link, and this:
echo "<a href='productdetail.php?product=" . $rij['productnaam'] . "'><img src='" . $rij['afbeelding_klein'] . "' alt'productafbeelding' /></a>";
doesnt? (not clickable).
thanks in advance!!
php rookie..
In the first one you have a real scr it's directing to with a file extension. the second does not. If the second is supposed to be picking up a variable we would need more information
echo "<a href='productdetail.php?product=" . $rij['productnaam'] . "'><img src='" . $rij['afbeelding_klein'] . "' alt='productafbeelding' /></a>";
just add a "=" between alt and 'productafbeelding'
Try this one:
echo '<img src="' . $rij['afbeelding_klein'] . '" alt="productafbeelding" />';