<img src="…/<?php echo "$ArtFilePath"; ?>">
gives me this. It’s actually the one I want only without the …
http://markdinwiddie.com/PHP2012/.../artwork/Drawings/Boy.jpg
<img src="../<?php echo "$ArtFilePath"; ?>">
give me this
http://markdinwiddie.com/artwork/Drawings/Boy.jpg
<img src="/../<?php echo "$ArtFilePath"; ?>">
gives me this
http://markdinwiddie.com/artwork/Drawings/Boy.jpg
and
<img src="/…/<?php echo "$ArtFilePath"; ?>">
gives me this
http://markdinwiddie.com/.../artwork/Drawings/Boy.jpg
What I need is
http://markdinwiddie.com/PHP2012/artwork/Drawings/Boy.jpg
Who knows the order of dots and slashes?
Since $artFilePath == "artwork/Drawings/Boy.jpg", you want either:
Relative urls
Provided your php file is within /PHP2012/ this will work. It will even work if you rename the directory
<img src="<?php echo $ArtFilePath ?>" />
Which outputs
<img src="artwork/Drawings/Boy.jpg" />
Absolute urls
<img src="/PHP2012/<?php echo $ArtFilePath ?>" />
Which outputs
<img src="/PHP2012/artwork/Drawings/Boy.jpg" />
if the webpage is within the PHP2012 folder: http://markdinwiddie.com/PHP2012/
and your image is in artwork/Drawings/Boy.jpg within the PHP2012 folder
can't you just do <img src="<?php echo "$ArtFilePath"; ?>">
Related
I am working on a WordPress website locally, where I am currently trying to dynamically call a Custom Header. I am using the following code:
<img src="<?php header_image(); ?>" height="20%<?php echo get_custom_header()->height; ?>" width="20%<?php echo get_custom_header()->width; ?>" alt="header-image" />
The above code, outputs the following line to the Browser:
<img src="http://localhost/wordpress-folder/wp-content/uploads/2017/10/image.jpg" height="20%3484" width="20%2439" alt="header-image" />
Though the above code successfully calls the Custom Header, it does fail W3C Validation. The error message is as follows:
Bad value 20%3484 for attribute height on element img: Expected a
digit but saw % instead.
The only way I can seem to remove this error, is by removing the % (px also produces the error) and only leave in the number.
Is there a way I could continue using Pixels/Percentage other than reorganising my code, so that I could implement some Inline/External Style Sheets?
You are using HTML height and width attributes. When you pass values to them you cannot pass the metric (e.g.: %, px etc) to it.
You will have to change your line to:
<img src="<?php header_image(); ?>" height="<?php echo get_custom_header()->height; ?>" width="<?php echo get_custom_header()->width; ?>" alt="header-image" />
Hope this helps. :)
This should throw an error as it's not in a correct format. It should be either in % format or px format. 20%3484 is an incorrect format.
If you want to give fixed height, you can use this:
<img src="<?php header_image(); ?>" height="<?php echo get_custom_header()->height; ?>" width="<?php echo get_custom_header()->width; ?>" alt="header-image" />
or if you want to use %, then use this:
<img src="<?php header_image(); ?>" height="20%" width="20%" alt="header-image" />
But you can only use one of them.
Let me know if it helps.
The name of the column is : link. variable-type:varchar.
<img src="<?php echo$link;?>" style="width:300px; height:400px;" />
</html>
Your echo command could be missing an ";"
$link=$row['link'];
<img src="<?php echo $link; ?>" style="width:300px; height:400px;" />
Should work better.
I've encountered this issue a couple times but have always found a "hack" way around it. Is there a special way to link an image in a WordPress template to an outside url beyond the typical a href tag? Here's the images I'm trying to link to outside urls:
<div class="socialMedia">
Follow Us: <br />
<img src="<?php echo get_bloginfo('template_url') ?>/images/facebook.png" alt="facebook"/>
<img src="<?php echo get_bloginfo('template_url') ?>/images/twitter.png" alt="twitter"/>
<img src="<?php echo get_bloginfo('template_url') ?>/images/googleplus.png" alt="google plus"/>
<img src="<?php echo get_bloginfo('template_url') ?>/images/instagram.png" alt="instagram"/>
</div><!--.socialMedia-->
<div class="socialMedia">
Follow Us: <br />
<a href="<?php echo get_bloginfo('template_url') ?>/images/facebook.png" target="_blank" > <img src="<?php echo get_bloginfo('template_url') ?>/images/facebook.png" alt="facebook"/> </a>
</div><!--.socialMedia-->
did you mean it!!?
<li><a href='#'>Core Transformation</a>
<img alt='arrow' src=**'http://localhost/wordpress1/wp-content/themes/twentytwelve/images/header-triangle.png'** /></li>
<li><a href=**'#'**>LINKS</a></li>
<li><a href=**'#'**>Contact Us</a></li>
How can I replace the src and href using the site_url() function?
You can use the following ways :
<img src="<?php bloginfo('template_url'); ?>/images/image.jpg" />
<img src="<?php echo get_template_directory_uri();?>/images/image.jpg" />
<img src="<?php home_url();?>/images/image.jpg" />
<img src="<?php echo site_url();?>/images/image.jpg"/>
you can do it same for href
More details refer codex
<img src="<?php echo site_url();?>/images/image.jpg"/>
or a better option would be:
<img src="<?php bloginfo('template_url'); ?>/images/image.jpg" />
You can do similarly for href
site_url() is used to append text on url.. so if you want to navigate to your directory and fetch something you can use it like this..
site_url('/images/default.jpg');
you can replace your src with following way:
<img src="<?php bloginfo('template_url'); ?>/images/yourimagename.extension" />
for more information about wordpress go to http://www.wpbeginner.com/wp-themes/wordpress-theme-cheat-sheet-for-beginners
that will help you more in future.
Still you getting any issues with that,then comment it.
I have a database that stores the path to the users image such as images/profile/950baasfaa88c.jpg. Now when i try to put this into a variable and surround it with image tags, only a blank image comes up not the image itself...
$profile_picture = $row['profile_image'];
<img src="'.$profile_picture.'" width=50 height=50 />
you haven't echo PHP
<img src="'.$profile_picture.'" width=50 height=50 />
should be
<img src="<?= $profile_picture ?>" width=50 height=50 />
you need to echo out the value
<img src="<?php echo $row['profile_image']; ?>" width=50 height=50 />