Support » Plugin: XO Featured Image Tools » Perfect tool with suggestion for improvement

  • Thank you for the great plugin. Is exactly what I was looking for and the best plugin you can find for this purpose…

    But:
    The following image URLs often appear in my posts:
    image.jpg?uid=Yi3w9CE.
    These image files are not captured by your plugin.

    So far I only knew this from form data transmissions like:
    index.html?var=123. But I have such pictures in my posts.

    Can you fix this in the next update please?

      My suggested solution would be:

    $path= substr( $url, strrpos( $url, ‘.’ )+4);
    $url = str_ireplace($path, ”, $url);

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author ishitaka

    (@ishitaka)

    Hi,

    This is a good suggestion and we have adopted it for version 1.9.0.
    Thanks for the review and suggestions.

    Thread Starter atallen

    (@atallen74)

    great job, thanks for the update.
    141 images are now created from 150 posts. These images are on the server of https://livingdocs.io/
    Each image needs an ID in the query parameters.
    See the following picture:
    https://server.livingdocs.io/api/v1/images/p-1110202.JPG?id=MQkvMjAyMi8wNS8xNS81OTAwMDg4Yy0wMmQyLTQ0ODMtODdmYi1hZDY5ZDEzNTUwMzAuanBlZwk4MTM%3D
    If you remove the query parameters here, the image can no longer be displayed.
    Is there a way that the plugin works with the attachments.?
    But it rarely happens that I get these posts, and then I can also embed the picture manually.
    Thank you for the plugin! It makes my work on my website much easier.

    Plugin Author ishitaka

    (@ishitaka)

    I think the following code will help.

    add_filter( 'xo_featured_image_tools_image_url', function( $url ) {
    
    	if ( 0 !== strpos( $url, 'https://example.com/' ) ) { return $url; }
    
    	$ch = curl_init( $url );
    	curl_setopt_array( $ch, array(
    		CURLOPT_HEADER         => true,
    		CURLOPT_NOBODY         => true,
    		CURLOPT_RETURNTRANSFER => true,
    		CURLOPT_SSL_VERIFYPEER => false,
    	) );
    	$content = curl_exec( $ch );
    	curl_close( $ch );
    
    	if ( preg_match( '/Location: (.*)/i', $content, $m ) ) {
    		$url = esc_url( trim( $m[1] ) );
    	}
    
    	return $url;
    } );

    Replace ‘example.com’ in the code with ‘server.livingdocs.io’, etc.

    Thread Starter atallen

    (@atallen74)

    Awesome, the code works perfectly.
    Thanks for your support…!!
    Will this code be overwritten with the next update…?
    Wouldn’t be bad, I can quickly install it again…

    greeting
    atallen

    Plugin Author ishitaka

    (@ishitaka)

    There are no plans to add it for the time being, as we have to create a screen for entering the URL. excuse me.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this review.