PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.13.3
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.13.3
3.13.3 3.13.2 3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 2.8.16 All 261 releases
wpfunnels / vendor / intervention / image / src / Intervention / Image / Commands / PsrResponseCommand.php

PsrResponseCommand.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 3.13.3, at vendor/intervention/image/src/Intervention/Image/Commands/PsrResponseCommand.php

45 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Intervention\Image\Commands;
4
5 use GuzzleHttp\Psr7\Response;
6
7 class PsrResponseCommand extends AbstractCommand
8 {
9 /**
10 * Builds PSR7 compatible response. May replace "response" command in
11 * some future.
12 *
13 * Method will generate binary stream and put it inside PSR-7
14 * ResponseInterface. Following code can be optimized using native php
15 * streams and more "clean" streaming, however drivers has to be updated
16 * first.
17 *
18 * @param \Intervention\Image\Image $image
19 * @return boolean
20 */
21 public function execute($image)
22 {
23 $format = $this->argument(0)->value();
24 $quality = $this->argument(1)->between(0, 100)->value();
25
26 //Encoded property will be populated at this moment
27 $stream = $image->stream($format, $quality);
28
29 $mimetype = finfo_buffer(
30 finfo_open(FILEINFO_MIME_TYPE),
31 $image->getEncoded()
32 );
33
34 $this->setOutput(new Response(
35 200,
36 [
37 'Content-Type' => $mimetype,
38 'Content-Length' => strlen($image->getEncoded())
39 ],
40 $stream
41 ));
42
43 return true;
44 }
45 }