WordPress.org

Ready to get started?Download WordPress

Forums

Image Widget
Relative paths (4 posts)

  1. ebanks
    Member
    Posted 2 years ago #

    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/

  2. ebanks
    Member
    Posted 2 years ago #

    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.

  3. ebanks
    Member
    Posted 2 years ago #

    Forgot to mention that it was in the plugins/image-widget/views/widget.php

  4. sillyname
    Member
    Posted 2 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic