• any hope of using an external URL?

    I know out of the box it doesn’t allow it, wondering if there is a php edit or trick to be able to use external images – adding images to posts allows it so hoping…

    thanks

Viewing 1 replies (of 1 total)
  • Plugin Author Jan-Willem

    (@janwoostendorp)

    Hi wasanajones,

    Not out of the box, but you could code it in.
    If you put this into your functions.php (Or in a lose plugin file.)
    And change the urls.

    function dfi_external_image($html, $post_id, $default_thumbnail_id, $size, $attr) {
        // add a class to the existing class list
    
        $alternate_url           = 'https://i.imgur.com/mtCQTvp.jpg';
    
        // add your own other sizes here (use <code>get_intermediate_image_sizes()</code> to check the defined sizes)
        if ($size == 'thumbnail') {
            // set smaller image
            $alternate_url = 'https://i.imgur.com/mtCQTvps.jpg';
        }
        
        $new_html = '<img src="' . $alternate_url . '" ';
        // @todo add correct image size attributes
        foreach ( $attr as $att => $value ) {
            $new_html .= "$att='$value' ";
        }
        $new_html .= '/>';
    
        return $new_html;
    
    }
    add_filter( 'dfi_thumbnail_html', 'dfi_external_image', 10, 5 );

    This will work out of the box, but it is a bit dirty, needs more sizes set, and should have the width and height attributes.

Viewing 1 replies (of 1 total)
  • The topic ‘External URL’ is closed to new replies.