I'm echoing some images using <div> <img src="<?php... construction.
The images are shown, but after each image there are always some strings left from my code.
part of my code is here:
getting image by:
$image01= wp_get_attachment_image(get_post_meta($id, 'image_case_01', true),'full');
and echoing image in <div>
<div class="images-container">
<div>
<img src="<?php echo $image01; ?>" >
</div>
</div>
Result - the image is echoed properly but after the image I have that string left from my code
> " >
If i use
<div class="images-container">
<div>
<img src="/.../.../xxx.jpg" />
</div>
</div>
then all is ok.
What is wrong with my code in 2. ?
could you try this ?
<div class="images-container">
<div> <?php echo '<img src="'.$image01.'"/>'; ?> </div>
</div>
you probably have quote probleme , i'm surprised the image actually showed up as your php code is inside a '"'
EDIT: some mistake
EDIT2: my bad
so i did this and it worked
<html lang="en">
<?php $image01="erreur.png";?>
<head>
<body>
<div>
<?php echo "<img src=".$image01."></img>"; ?>
</div>
</head>
</body>
I found a solution for me.
Instead of using wp_get_attachment_image i used wp_get_attachment_image_src
Now everything works as expected.
I still don't understand why i had such quotes aoround my images, which probably lead to my problems.
May be it is because I'm getting images from a metabox meatfield.
Thank You for your support.
Related
In this little snippet of code ,i show how i take the "foto1" column of my database and transfer the value of it to a variable in c# named $foto.
The $foto contains the path of the image corresponding to the product that is showing up. Ive tried to copy and paste the path and ditch out the php part and it works. But when i put it in img src it gives me like the broken image thing.And i cant figure out why it does that.
All help is aprecciated .
Have a nice day :)
<div class="row shop_box-top">
<?php
$ligaBD=odbc_connect('basededadospap','','');
$sql="SELECT * FROM produto WHERE nome_produto LIKE '%ADIDAS%'";
$resultado=odbc_exec($ligaBD,$sql);
?>
<div class="row shop_box-top">
<?php
while (odbc_fetch_row($resultado))
{
$nome = odbc_result($resultado,2);
$preco= odbc_result($resultado,4);
$foto = odbc_result($resultado,9);
?>
<div class="col-md-3 shop_box"><a href="stansmithflatwhite.html">
<img src="<?php echo $foto; ?>" class="img-responsive" alt=""/>
<span class="new-box">
<span class="new-label">Novo</span>
</span>
<div class="shop_desc">
<h3><?php echo $nome; ?></h3>
<span class="actual"><?php echo $preco; ?></span><br>
</div>
</a></div>
<?php }?>
depends of what path contains the $foto var. If is the absolute path, you have to retrive the relative path.
Try also to append an / or an http[s] in front of the path
<img src="/<?php echo $foto;?>">
So it would be : //path/to/photo
As I can see it in your comment, your image paths contain spaces, so a possible solution can be to use urlencode() before echoing them.
Try passing full path to img tag like http://localhost/xyz/images/Cal�ado/Adidas/Homem/Stan Smith/ADIDAS STAN SMITH - RED/ch-adidas-stan-smith-red-5.jpg.
Replace "localhost/xyz" with your website directory path.
imagedisplay.php(view)
<html>
<body>
<h3>Your file was successfully uploaded!</h3>
<?php print_r($upload_data); ?> </br>
<?php $str=base_url()."images/".$upload_data['file_name'] ?> </br>
<?php $str=str_replace('http://','',$str) ?>
<?php echo $str; ?>
<img src= '$str'/> </br>
For echo $str; I got the string i need to display th image
but when i pass it to img src.... i am not able to display it on the browswer
Is there any syntactical error or am i missing anything ...pls help?
Just a small syntax problem here.
Embed PHP echo command in the HTML code, like so:
<img src="<?php echo $str; ?>"/> </br>
or embed PHP echo short tags:
<img src="<?=$str?>"/> </br>
In other words: insert the PHP output at the positions, where you need it as HTML content.
I am developing a gallery website where users can visit images that other people have shared. I have created the gallery and images can be viewed using thumbnails and the images upload from the right of the previsous image. If an image is at the edge of the page the next image will go in the row beneath it. I use this code to do this:
<?php
mysql_connect("localhost","root","");
mysql_select_db("pardeepsandhu");
$res= mysql_query("select * from images");
$row=mysql_fetch_array($res)
?>
<div id="w">
<div id="content">
<div id="images"><?php while ($row=mysql_fetch_array($res)){?>
<img src="<?php echo $row["Image"]; ?>" height="134.1175" width="134.1175" border="5" alt="turntable" />
<?php } ?>
</div>
</div>
</div>
<script type="text/javascript">
$(function() {
$('#images a').lightBox();
});
</script>
However, i am now trying to get a voting system set up. At the bottom of each image there would be a button which will give an image a like. The button works however the images, with the buttons, are being laid out differently. All the images appear one beneath the other, it looks like they are in on column. I don't want this to happen as space will be wasted. This is the code with a button:
<div id="w">
<div id="content">
<div id="images"><?php while ($row=mysql_fetch_array($res)){?>
<img src="<?php echo $row["Image"]; ?>" height="134.1175" width="134.1175" border="5" alt="turntable" />
<form id="form1" name="form1" method="post" action="">
<input type="submit" name="button" id="button" value="Like this image" />
</form>
<?php } ?>
How do I get the images to load like they did before, so that they appear in rows rather than in one column. Can anyone help me?
To achieve a horizontal layout, you will need to use the css "display:inline-block;" on all of your image / link containers. If I were you, I would have another div which contains all the image and voting info. Also, please make sure you are closing all of your divs as this can dramatically change your layout.
Something along the lines of this should get them horizontal.
<div id="pic" style="display: inline-block;">
<img src="">
<form></form>
</div>
http://jsfiddle.net/u9gSD/
Hello I have in my DB a column called capalivro that has my image paths.
I want to make the img src the content of that column, but I'm not succeding in doing this since I don't know how to put that PHP var in the HTML.
This way I tried doesn't work because the php doesn't work because of the quotation marks.
<?php while ($livro = mysql_fetch_assoc($livrotodos)) { ?>
<div class="large-2 columns">
<div class="livro">
<div class="livro-overlay">
<h3><?php echo $livro['nomelivro'] ?></h3>
</div>
<img src= "<?php $livro['capalivro']?>" />
</div>
</div>
<?php }
?>
</div>
<img src= "<?php $livro['capalivro']?>" />
</div>
should be:
</div>
<img src= <?php echo "\"". $livro['capalivro']."\""?> />
</div>
change your line containing the img src= bit to:
<img src="<?php echo $livro['capalivro']?>" />
without the echo part, it won't display the "string" from the database.
I don't know how to describe my question because I don't even know this is an error or not!
In most of my works there are some empty space inside html.
I know some space or other special characters are skip from rendering of browsers but this one never skips!
in my php file I have one include exactly near that space.
how can I remove that? thanks in advance...
<div class="pg-picture">
<img src="img/top-pic/1375022681.jpg" alt="" width="353px" height="145px" /></div> </div>
</div>
</div>
<div id="section">
<div class="container clearfix">
<script type="text/javascript">
setTitle('title');
</script>
css:
html,body,.container{min-height:100%}
.container{margin:0 auto;position:relative;width:990px}
html>body .clearfix:after{clear:both;content:" ";display:block;font-size:0;height:0;visibility:hidden;*zoom:1}
* html .clearfix{height:1%}
Try changing content:" " in your css to content="".
What is a clearfix?