Title: [Plugin: Image Widget] Relative paths
Last modified: August 20, 2016

---

# [Plugin: Image Widget] Relative paths

 *  [ebanks](https://wordpress.org/support/users/ebanks/)
 * (@ebanks)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-image-widget-relative-paths/)
 * Hi,
 * Is it possible to enter a relative path to the selected image so that I don’t
   have to change the image manualy everytime I deploy my website.
 * I’d like to have the image in a relative path to fix this issue.
 * Thanks for your help.
 * [http://wordpress.org/extend/plugins/image-widget/](http://wordpress.org/extend/plugins/image-widget/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [ebanks](https://wordpress.org/support/users/ebanks/)
 * (@ebanks)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-image-widget-relative-paths/#post-2366054)
 * Here’s the solution i’ve found.
 * Adding
 * // Find the base URL
    $baseUrl = get_bloginfo ( ‘siteurl’ );
 * // remove the base url and convert to relative path
    $imageurl = str_replace(
   $baseUrl, “”, $imageurl);
 * before the original code below
 * echo “<img src=\”{$imageurl}\” style=\””;
    if ( !empty( $width ) && is_numeric(
   $width ) ) { echo “max-width: {$width}px;”; }
 * If you had other solutions don’t hesitate to share.
 *  Thread Starter [ebanks](https://wordpress.org/support/users/ebanks/)
 * (@ebanks)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/plugin-image-widget-relative-paths/#post-2366055)
 * Forgot to mention that it was in the plugins/image-widget/views/widget.php
 *  [sillyname](https://wordpress.org/support/users/sillyname/)
 * (@sillyname)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/plugin-image-widget-relative-paths/#post-2366406)
 * Thanks for the workaround, tried it but I failed.
    Could you tell me exactly 
   where you are putting your code, thanks.
 *     ```
       <?php
       echo $before_widget;
       if ( !empty( $title ) ) { echo $before_title . $title . $after_title; }
       if ( !empty( $image ) ) {
       	if ( $link ) {
       		echo '<a class="'.$this->widget_options['classname'].'-image-link" href="'.$link.'" target="'.$linktarget.'">';
       	}
       	if ( $imageurl ) {
       			echo "<img src=\"{$imageurl}\" style=\"";
       		if ( !empty( $width ) && is_numeric( $width ) ) {
       			echo "max-width: {$width}px;";
       		}
       ```
   
 * Are you inserting it in the curly before
    `echo "<img src=\"{$imageurl}\" style
   =\"";`
 * Or does anyone else have a solution?

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘[Plugin: Image Widget] Relative paths’ is closed to new replies.

 * ![](https://ps.w.org/image-widget/assets/icon-256x256.png?rev=2489603)
 * [Image Widget](https://wordpress.org/plugins/image-widget/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/image-widget/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/image-widget/)
 * [Active Topics](https://wordpress.org/support/plugin/image-widget/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/image-widget/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/image-widget/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [sillyname](https://wordpress.org/support/users/sillyname/)
 * Last activity: [14 years, 6 months ago](https://wordpress.org/support/topic/plugin-image-widget-relative-paths/#post-2366406)
 * Status: not resolved