From: stephen@cubedesigners.com Date: Thu, 19 Mar 2020 15:20:35 +0000 (+0000) Subject: Wait #3413 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=5239efd3a9d2ce9dbbad02f7b50eb83c994b3f60;p=ccgm.git Wait #3413 @0.5 --- diff --git a/framework/application/forms/CMS/Sub/News/News.php b/framework/application/forms/CMS/Sub/News/News.php index 8e0592d..069dcc1 100644 --- a/framework/application/forms/CMS/Sub/News/News.php +++ b/framework/application/forms/CMS/Sub/News/News.php @@ -19,8 +19,13 @@ class CCGM_Form_CMS_Sub_News_News extends CubeIT_Form_List_Model { $date->setLabel(__('Date')); $this->addElement($date); + $thumbnail = new CubeIT_Form_Element_File_Image('thumbnail'); + $thumbnail->setLabel('Vignette'); + $thumbnail->setMaxItems(1); + $this->addElement($thumbnail); + $image = new CubeIT_Form_Element_File_Image('image'); - $image->setLabel('Images'); + $image->setLabel('Galerie des images'); $this->addElement($image); $videos = new Zend_Form_Element_Textarea('videos'); diff --git a/framework/application/models/News.php b/framework/application/models/News.php index ea636c4..dfd5b5b 100644 --- a/framework/application/models/News.php +++ b/framework/application/models/News.php @@ -3,6 +3,7 @@ class CCGM_Model_News extends CubeIT_Model_Data_Table { protected static $_table = 'news'; + protected $thumbnail; protected $title; protected $date; protected $content; @@ -19,6 +20,7 @@ class CCGM_Model_News extends CubeIT_Model_Data_Table { $table->addColumn('date', 'datetime'); $table->addColumn('content', 'text'); $table->addColumn('link', 'text'); + $table->addColumn('thumbnail', 'text'); $table->addColumn('image', 'text'); $table->addColumn('videos', 'text'); $table->addColumn('pdf', 'text'); @@ -34,7 +36,12 @@ class CCGM_Model_News extends CubeIT_Model_Data_Table { $this->view = Zend_Controller_Action_HelperBroker::getExistingHelper('ViewRenderer')->view; - $img = $this->view->imageProcess($this->getImage(), '', $width, $height, ['class' => $class]); + $img = $this->view->imageProcess($this->getThumbnail(), '', $width, $height, ['class' => $class]); + + // Fallback to other uploaded images if no thumbnail is set + if (!$img) { + $img = $this->view->imageProcess($this->getImage(), '', $width, $height, ['class' => $class]); + } // No images found in 'image' field, so look for a video frame if (!$img) {