Forum Replies Created

Viewing 1 replies (of 1 total)
  • Here’s a fix that’s all in code:

    replace

    header('Content-type: image/jpeg');

    with

    header('Content-type: image/png'); // set the content type
    $blankimg = imagecreatetruecolor(1,1); // create an image
    imagesavealpha($blankimg, TRUE); // enable transparency saving
    $trans_color = imagecolorallocatealpha($blankimg, 0, 0, 0, 127); // set the transparent "color"
    imagefill($blankimg, 0, 0, $trans_color); // fill the image
    imagepng($blankimg); // output the image
    imagedestroy($blankimg); // clear memory

    The problem is that the php is sending a content type header, telling the browser that the subsequent data is an image… but then it doesn’t send any data, so the browser interprets that as a missing image. The code above simply creates a transparent 1px png and sends the data. That way you don’t need to perform a redirect as in the solution above.

Viewing 1 replies (of 1 total)