Home how to use images in wordpress by local link?
Reply: 1

how to use images in wordpress by local link?

K. ossama
1#
K. ossama Published in 2018-01-12 20:24:10Z

In this code, I wanna use an internal image that is saved in my laptop. The code used is copied and it was using an external link. The problem is the image doesn't appear after changing the path, so tell me if I missed something. Thanks in advance

    <div class="row home-team">
<div class="col-md-3 col-sm-6 dream-team-item">
<div class="row dream-team-detail">
<div class="img-thumbnail">
<p><img class="img-responsive home_team_thumb wp-post-image" src="C:/xampp/htdocs/wordpress/wp-content/themes/dream/images/image.jpg" alt="" width="1140" height="760"></p>
<div class="overlay"></div>
</div>
<h3 class="member-name"><a href="#"> Name</a></h3>
<p>( Age)</p>
</div>
</div>

and here is the original code :

 <div class="col-md-3 col-sm-6 dream-team-item">
    <div class="row enigma-team-detail">
    <div class="img-thumbnail">
    <p><img class="img-responsive home_team_thumb wp-post-image" src="http://demo.com/dream-premium/wp-content/uploads/sites/23/2016/10/team1-1140x760.jpg" alt="" width="1140" height="760"></p>
    <div class="overlay"></div>
    </div>
    <h3 class="member-name"><a href="#"> Thomash</a></h3>
    <p>( CEO)</p>
    </div>
    </div>
hutuh
2#
hutuh Reply to 2018-01-12 20:50:24Z

I see that the paths are different, in this case, I would suggest using the same folder for the image (themes or uploads).

If you want to use the "themes" folder in both environments(web and localhost), you can use like this:

<?php
  #this line below returns http://yourwebsite/wp-content/themes
  $themes_path = get_theme_root_uri();  
?>
<p><img class="img-responsive home_team_thumb wp-post-image" src="<?=$themes_path;?>/dream/images/image.jpg" alt="" width="1140" height="760"></p>

Now if you would like to keep on the "uploads" folder, you can do this:

<?php
  $upload_dir   = wp_upload_dir();
?>
<p><img class="img-responsive home_team_thumb wp-post-image" src="<?=$upload_dir['baseurl'];?>/sites/23/2016/10/team1-1140x760.jpg" alt="" width="1140" height="760"></p>

Using $upload_dir['basedir'] you get the full url "http://yourwebsite/wp-content/uploads/ or http://localhost/wp-content/uploads/";

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.43026 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO