You are here

public function CaptchaImageResponse::sendContent in CAPTCHA 8

File

image_captcha/src/Response/CaptchaImageResponse.php, line 109

Class

CaptchaImageResponse
Response which is returned as the captcha for image_captcha.

Namespace

Drupal\image_captcha\Response

Code

public function sendContent() {
  if (!$this->image) {
    return;
  }

  // Begin capturing the byte stream.
  ob_start();
  $file_format = $this->config
    ->get('image_captcha_file_format');
  if ($file_format == IMAGE_CAPTCHA_FILE_FORMAT_JPG) {
    imagejpeg($this->image);
  }
  else {
    imagepng($this->image);
  }

  // Clean up the image resource.
  imagedestroy($this->image);
}