Pass query string to page

This should actually work for you:

function header_resized_img () {
    $image = wp_get_image_editor($_GET['path']);
    $height = $_GET['height'];
    $width =  $_GET['width'];
    if (!is_wp_error($image)) {
        $image->resize(9999, $height, false);
        $orig_size = $image->get_size();
        $image->crop($orig_size['width']/2-$width/2, $orig_size['height']/2-$height/2, $width, $height);
        $image->stream( $mime_type="image/jpeg");
    }
}

and include your function somewhere in the template:

header_resized_img();

Then try accessing this URL:

http://example.com/image/?width=500&height=400&path=some-url

To generate your image.

Leave a Comment