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;
    }