vendor/contao/core-bundle/src/Resources/contao/elements/ContentText.php line 54

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of Contao.
  4. *
  5. * (c) Leo Feyer
  6. *
  7. * @license LGPL-3.0-or-later
  8. */
  9. namespace Contao;
  10. /**
  11. * Front end content element "text".
  12. */
  13. class ContentText extends ContentElement
  14. {
  15. /**
  16. * Template
  17. * @var string
  18. */
  19. protected $strTemplate = 'ce_text';
  20. /**
  21. * Generate the content element
  22. */
  23. protected function compile()
  24. {
  25. // Add the static files URL to images
  26. if ($staticUrl = System::getContainer()->get('contao.assets.files_context')->getStaticUrl())
  27. {
  28. $path = System::getContainer()->getParameter('contao.upload_path') . '/';
  29. $this->text = str_replace(' src="' . $path, ' src="' . $staticUrl . $path, (string) $this->text);
  30. }
  31. $this->Template->text = StringUtil::encodeEmail((string) $this->text);
  32. $this->Template->addImage = false;
  33. $this->Template->addBefore = false;
  34. // Add an image
  35. if ($this->addImage)
  36. {
  37. $figure = System::getContainer()
  38. ->get('contao.image.studio')
  39. ->createFigureBuilder()
  40. ->from($this->singleSRC)
  41. ->setSize($this->size)
  42. ->setOverwriteMetadata($this->objModel->getOverwriteMetadata())
  43. ->enableLightbox((bool) $this->fullsize)
  44. ->buildIfResourceExists();
  45. if (null !== $figure)
  46. {
  47. $figure->applyLegacyTemplateData($this->Template, $this->imagemargin, $this->floating);
  48. }
  49. }
  50. }
  51. }
  52. class_alias(ContentText::class, 'ContentText');