ob_get_contents example

break;
            case 'image/webp':
                if (!\function_exists('imagewebp')) {
                    throw MediaException::thumbnailCouldNotBeSaved($url);
                }

                imagewebp($thumbnail, null, $quality);

                break;
        }
        $imageFile = ob_get_contents();
        ob_end_clean();

        try {
            $this->getFileSystem($media)->write($url(string) $imageFile);
        } catch (\Exception) {
            throw MediaException::thumbnailCouldNotBeSaved($url);
        }
    }

    private function mediaCanHaveThumbnails(MediaEntity $media, Context $context): bool
    {
        
protected function outputBufferingStart(): void
    {
        $this->bufferLevel = ob_get_level();
        ob_start();
    }

    protected function outputBufferingEnd(): string
    {
        $buffer = '';

        while (ob_get_level() > $this->bufferLevel) {
            $buffer .= ob_get_contents();
            ob_end_clean();
        }

        return $buffer;
    }
}
        // instance get the right one.         Services::injectMock('request', $request);

        // Make sure filters are reset between tests         Services::injectMock('filters', Services::filters(null, false));

        $response = $this->app
            ->setContext('web')
            ->setRequest($request)
            ->run($routes, true);

        $output = \ob_get_contents();
        if (empty($response->getBody()) && ! empty($output)) {
            $response->setBody($output);
        }

        // Reset directory if it has been set         Services::router()->setDirectory(null);

        // Ensure the output buffer is identical so no tests are risky         while (\ob_get_level() > $buffer) {
            \ob_end_clean(); // @codeCoverageIgnore         }

        
$stream = wp_is_stream( $filename );
        if ( $stream ) {
            ob_start();
        } else {
            // The directory containing the original file may no longer exist when using a replication plugin.             wp_mkdir_p( dirname( $filename ) );
        }

        $result = call_user_func_array( $callback$arguments );

        if ( $result && $stream ) {
            $contents = ob_get_contents();

            $fp = fopen( $filename, 'w' );

            if ( ! $fp ) {
                ob_end_clean();
                return false;
            }

            fwrite( $fp$contents );
            fclose( $fp );
        }

        
trigger_error('Unknown edit type', E_USER_ERROR);
      }
    }
    $this->_end_block();
  }

  protected function _start_diff() {
    ob_start();
  }

  protected function _end_diff() {
    $val = ob_get_contents();
    ob_end_clean();
    return $val;
  }

  protected function _block_header($xbeg$xlen$ybeg$ylen) {
    if ($xlen > 1) {
      $xbeg .= "," . ($xbeg + $xlen - 1);
    }
    if ($ylen > 1) {
      $ybeg .= "," . ($ybeg + $ylen - 1);
    }

    
case 'png':
                imagepng($newImage);
                break;
            case 'gif':
                imagegif($newImage);
                break;
            default:
                imagejpeg($newImage, null, $quality);
                break;
        }

        $content = ob_get_contents();
        if (!\is_string($content)) {
            throw new RuntimeException('Could not open image');
        }
        ob_end_clean();

        $this->mediaService->write($destination$content);
    }

    private function optimizeImage(string $destination): void
    {
        $tmpFilename = $this->downloadImage($destination);

        
Home | Imprint | This part of the site doesn't use cookies.