Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @masterchef93

    I hope you are doing well.

    I am afraid we don’t have an integration implemented yet, but had you tries the suggestion from this reply?

    https://www.ads-software.com/support/topic/local-image-links-show-broken-when-using-cdn/#post-12434208

    You can add the string of your upload path ( local server ) on WordPress Settings > Link Checker > Which Links To Check

    Let us know if this worked for you.
    Best Regards
    Patrick Freitas

    Thread Starter Eric

    (@masterchef93)

    Hi @wpmudevsupport12,

    Thanks for your reply. Unfortunately, the solution to exclude the path to the images from the check won’t work for me, because I am looking specifically for broken images.

    I have come up with a solution by modifying the plugin.
    In the file //broken-link-checker/core/core.php I added:

    $mysiteurl ="//mysite.com/wp-content/uploads/";
     $amazons3url = "//mysitewp.s3.amazonaws.com/wp-content/uploads/";
     $originallink = $link->url;
     $link->url = str_replace($mysiteurl,$amazons3url,$originallink);

    Add the above immediately before $link->chck( true ) in the work() function.

    Now when I am running the broken link checker, I am getting 404 errors only on the images that are actually broken, as the URLs for the images moved by WP Offload Media are correctly passed to the checker.

    I realize that this fix will not survive a plugin update. But in the short term, it seems to do the trick. If you see other issues with this solution, please let me know.

    Thanks,
    eric

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @masterchef93

    This sounds like a good filter option actually if we had a filter for it this could be easily managed on the hook.

    About the plugin update, we don’t have an estimated time to release the new version, our developers are working on some big interface updates but there is no ETA yet, so the change will keep for a while without any problem.

    Best Regards
    Patrick Freitas

    Thread Starter Eric

    (@masterchef93)

    Sweet!

    Thanks for the support @wpmudevsupport12 and for the very helpful plugin.

    I have exactly the same issue on my site – is it worth implementing Eric’s solution or is the promised update imminent?

    Are there any pros/cons to simply manually marking those reported links as “not broken” or as “dismissed”?

    Thanks
    Ian.

    PS. Sorry to hijack someone else’s thread but it seemed sensible for future searches to keep the information all in one place rather than over two threads.

    Thread Starter Eric

    (@masterchef93)

    I think a negative of just marking all of them as “not broken” is if one really was broken, then it would never get resolved/corrected.

    Thanks Eric – that’s a fair point.

    Have you found that you have had to re-implement your fix often (ie does the frequency of updates to the plug-in cause issues)?

    Plugin Support Williams – WPMU DEV Support

    (@wpmudev-support8)

    Hi @ianbutty

    is it worth implementing Eric’s solution or is the promised update imminent?

    I’m afraid I don’t have an ETA on updates. For now, any “workaround” that works for you would be worth applying (e.g. Eric’s solution), at least until major update is released.

    Kind regards,
    Adam

    Thread Starter Eric

    (@masterchef93)

    Hi @ianbutty – I have not re-implemented the fix; I only needed to do the scan for those files after a migration – so it was kind of a one-time (or very infrequent) need for me.

    Hi Adam
    Thanks for the info – I’ll see if I can get Eric’s work round to work.

    Hi Eric
    I tried the fix but I’m struggling to get it to work.
    I couldn’t find “$link->chck( true )” in the code
    but did find two instances of “$link->check( true )”

    Adding the suggested fix before the one in function work() didn’t appear to make any difference.

    The second instance is in function ajax_recheck() which did make a difference BUT now I get “403 forbidden” as the result of the check. Presumably, this is because broken link checker doesn’t know my S3 access key/credentials?

    Thread Starter Eric

    (@masterchef93)

    @ianbutty I haven’t looked at this in several months, so I don’t know what changes they may have made in the plugin function…but in my code example did you change the $mysiteurl variable to include your actual domain?

    Oh yes…! (I hope I have formatted this correctly for the forum!

    Here in work()

    foreach ( $links as $link ) {
    					//Does this link need to be checked? Excluded links aren't checked, but their URLs are still
    					//tested periodically to see if they're still on the exclusion list.
    					if ( ! $this->is_excluded( $link->url ) ) {
    						//Check the link.
    						//FB::log($link->url, "Checking link {$link->link_id}");
    						
    						// ******** Code added by IMB 
    						
    						$mysiteurl ="//making-photos.co.uk/wp-content/uploads/";
                            $amazons3url = "//makingphotos.s3.eu-west-2.amazonaws.com/wp-content/uploads/";
                            $originallink = $link->url;
                            $link->url = str_replace($mysiteurl,$amazons3url,$originallink);
    
    						// ******** End Code added by IMB 
    
    						$link->check( true );
    					} else {

    and in ajax_recheck() ….

    //In case the immediate check fails, this will ensure the link is checked during the next work() run.
    $link->last_check_attempt = 0;
    $link->isOptionLinkChanged = true;
    $link->save();

    //Check the link and save the results.

    // ******** Code added by IMB

    $mysiteurl =”//making-photos.co.uk/wp-content/uploads/”;
    $amazons3url = “//makingphotos.s3.eu-west-2.amazonaws.com/wp-content/uploads/”;
    $originallink = $link->url;
    $link->url = str_replace($mysiteurl,$amazons3url,$originallink);

    // ******** End Code added by IMB

    $link->check( true );`

    Hopefully, you will spot something that I have missed.

    • This reply was modified 3 years, 2 months ago by ianbutty.
    Thread Starter Eric

    (@masterchef93)

    Hey @ianbutty

    I looked over this and nothing jumps out at me as what might be going wrong. But it’s been a while since I needed to dig into this and I haven’t kept up with how that code has been updated in later versions. So, maybe there’s another function somewhere that is defining the link check process?

    Perhaps @wpmudev-support8 could give some input?

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @masterchef93 & @ianbutty

    First, we need to verify the result of the cURL request, when we get the 403 forbidden it can be the S3 returning this status, what happens when you check the link directly using the cURL?

    $ curl -IL -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36" https://amazonlink..

    Best Regards
    Patrick Freitas

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘WP Offload Media – 404 for images’ is closed to new replies.