Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Plugin Name: Bypass Amazon Images
- */
- add_action('init', function(){
- ob_start(function($buffer){
- preg_replace_callback('~url\('([^']*)url=(.*)'\)~', function($matches){
- $url = base64_decode($matches[2]);
- $image = wp_remote_get($url);
- if (!is_wp_error($image)){
- $upload = wp_upload_dir();
- $filename = 'aws-' . $matches[2].jpg, $image['response']['body'];
- file_put_contents(trailingslashit($upload['path']) . $filename);
- return "url('" . trailingslashit($upload['url']) . $filename . "')";
- }
- return $matches[0];
- }, $buffer);
- });
- });
Add Comment
Please, Sign In to add comment