1

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>
K. ossama
  • 403
  • 1
  • 4
  • 15
  • Possible duplicate of [src absolute path problem](https://stackoverflow.com/questions/5157772/src-absolute-path-problem) – Cave Johnson Jan 12 '18 at 20:37

1 Answers1

3

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/";

mad4n7
  • 171
  • 7
  • This is correct. you should always use the family of functions like `get_theme_root_uri()` and `get_stylesheet_directory_uri()`, as that makes your theme more portable. – JakeParis Jan 12 '18 at 21:46