private function fixHTMLFieldsForPreview($record)
    {
        foreach ($record->contenttype['fields'] as $fieldSlug => $fieldSettings) {
            if (in_array($fieldSettings['type'], ['html', 'text', 'textarea', 'markdown'])) {
                $fieldValue = new \Twig_Markup($this->getFieldValue($record, $fieldSlug), "UTF-8");

                $this->setFieldValue($record, $fieldSlug, $fieldValue);
            }
            if ($fieldSettings['type'] === 'image') {
                $fieldValue = $this->getFieldValue($record, $fieldSlug);

                if (is_array($fieldValue) && isset($fieldValue['file'])) {
                    $this->setFieldValue($record, $fieldSlug, $fieldValue['file']);
                }
            }
        }

        return $record;
    }
private function fixHTMLFieldsForPreview($record)
    {
        foreach ($record->contenttype['fields'] as $fieldSlug => $fieldSettings) {
            if (in_array($fieldSettings['type'], ['html', 'text', 'textarea', 'markdown'])) {
                $fieldValue = new \Twig_Markup($this->getFieldValue($record, $fieldSlug), "UTF-8");

                $this->setFieldValue($record, $fieldSlug, $fieldValue);
            }
            if ($fieldSettings['type'] === 'image') {
                $fieldValue = $this->getFieldValue($record, $fieldSlug);

                if (is_array($fieldValue) && isset($fieldValue['file'])) {
                    $this->setFieldValue($record, $fieldSlug, $fieldValue['file']);
                }
            }
        }

        return $record;
    }
private function fixHTMLFieldsForPreview ( $ record ) { foreach ( $ record -> contenttype [ 'fields' ] as $ fieldSlug => $ fieldSettings ) { if ( in_array ( $ fieldSettings [ 'type' ] , [ 'html' , 'text' , 'textarea' , 'markdown' ] ) ) { $ fieldValue = new \ Twig_Markup ( $ this -> getFieldValue ( $ record , $ fieldSlug ) , "UTF-8" ) ; $ this -> setFieldValue ( $ record , $ fieldSlug , $ fieldValue ) ; } if ( $ fieldSettings [ 'type' ] === 'image' ) { $ fieldValue = $ this -> getFieldValue ( $ record , $ fieldSlug ) ; if ( is_array ( $ fieldValue ) && isset ( $ fieldValue [ 'file' ] ) ) { $ this -> setFieldValue ( $ record , $ fieldSlug , $ fieldValue [ 'file' ] ) ; } } } return $ record ; }
Helper function to make sure HTML-like fields are Twig_Markup, and image fields are
an image. Like they are in a "real" page.

This is needed to make previewing content with block fields fully working.
See: https://github.com/bolt/bolt/issues/7753
Helper function to make sure HTML - like fields are Twig_Markup and image fields are an image . Like they are in a real page .