Verwendung: Bildgrössen aus Backend werden im Frontend nicht verarbeitet

bernhard's Avatar

bernhard

10 Feb, 2021 07:23 AM

Produkt: Custom Elements Contao
Contao-Version: 4.10

Hallo,
ich setze zusätzlich zur Bildauswahl noch die fields/size mit ein.
gemäss dump($this) werden die Werte auch ins template gebracht, nur greifen die Grössen im Bild nicht.
Ausschnitt rsce_portfolio_config.php:
'portfolios' => [ 'label' => [ 'de' => ['Portfolio',''], ], 'elementLabel' => '%s. Box', 'inputType' => 'list', 'minItems' => 1, 'fields' => [ 'backgroundimage' => [ 'label' => [ 'de' => [ 'Hintergrundbild','Wählen Sie ein Hintergrundbild für den Teaser.' ], ], 'dependsOn' => [ 'field' => 'backgroundmedia', 'value' => ['bg-image','bg-vimeo'], ], 'inputType' => 'fileTree', 'eval' => [ 'tl_class' => 'clr', 'fieldType' => 'radio', 'filesOnly' => true, 'extensions' => \Config::get('validImageTypes'), ], ], 'size' => [ 'label' => [ 'de' => [ 'Bildgrösse','Hier können Sie die Abmessungen des Bildes und den Skalierungsmodus festlegen.' ], ], 'dependsOn' => [ 'field' => 'backgroundmedia', 'value' => ['bg-image','bg-vimeo'], ], 'inputType' => 'imageSize', 'eval' => [ 'rgxp'=>'natural', 'includeBlankOption'=>true, 'nospace'=>true, 'tl_class'=>'w50', ], 'options_callback' => static function () { return System::getContainer()->get('contao.image.image_sizes')->getOptionsForUser(BackendUser::getInstance()); }, 'reference' => &$GLOBALS['TL_LANG']['MSC'], ],

Ausschnitt rsce_portfolio.html5:

  1. 1 Posted by bernhard on 10 Feb, 2021 07:24 AM

    bernhard's Avatar

    <div class="<?php echo implode(' ', $cssCanvas) ?>"<?php echo $this->cssID ?>>
        <?php $count=1; foreach ($this->portfolios as $portfolio): ?>
        <?php $backimage = $this->getImageObject($portfolio->backgroundimage);
            if ($portfolio->backgroundmedia == 'bg-image') {
                $dataicon ='&#xe0cb;';
            } elseif ($portfolio->backgroundmedia == 'bg-gallery') {
                $dataicon ='&#xe0f2;';
            } else $dataicon ='&#x25b6;';
            
        ?>
        <article class="portfolio-item column <?php echo $portfolio->gridclass ?>">
            <div class="grid-inner">
                <div class="portfolio-image">
                    <a href="<?php echo $portfolio->url ?>">
                        <?php if ($backgroundimage = $this->getImageObject($portfolio->backgroundimage, $portfolio->size)): ?>
                        <?php $this->insert('picture_default', $backimage->picture) ?>
                        <?php endif ?>
                    </a>

  2. 2 Posted by bernhard on 10 Feb, 2021 08:01 AM

    bernhard's Avatar

    Fehler meinerseits - konnte gelöst werden
    IST: <?php if ($backgroundimage = $this->getImageObject($portfolio->backgroundimage, $portfolio->size)): ?>
    SOLL: <?php if ($backimage = $this->getImageObject($portfolio->backgroundimage, $portfolio->size)): ?>

  3. bernhard closed this discussion on 10 Feb, 2021 08:01 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac