Procházet zdrojové kódy

#1224 Text based modules: first uploaded image should be automatically selected as cover image

Alex Trofimov před 8 roky
rodič
revize
cd78d58700

+ 2 - 1
modules/base/general/classes/BxBaseModGeneralFormEntry.php

@@ -138,7 +138,8 @@ class BxBaseModGeneralFormEntry extends BxTemplFormView
 			'name' => $this->aInputs[$CNF['FIELD_PHOTO']]['name'],
 			'content_id' => $this->aInputs[$CNF['FIELD_PHOTO']]['content_id'],
 			'editor_id' => isset($CNF['FIELD_TEXT_ID']) ? $CNF['FIELD_TEXT_ID'] : '',
-			'thumb_id' => isset($CNF['FIELD_THUMB']) && isset($aContentInfo[$CNF['FIELD_THUMB']]) ? $aContentInfo[$CNF['FIELD_THUMB']] : 0,
+            'thumb_id' => isset($CNF['FIELD_THUMB']) && isset($aContentInfo[$CNF['FIELD_THUMB']]) ? $aContentInfo[$CNF['FIELD_THUMB']] : 0,
+            'name_thumb' => isset($CNF['FIELD_THUMB']) ? $CNF['FIELD_THUMB'] : '',
 			'bx_if:set_thumb' => array (
 				'condition' => CHECK_ACTION_RESULT_ALLOWED === $this->_oModule->checkAllowedSetThumb($this->aInputs[$CNF['FIELD_PHOTO']]['content_id']),
 				'content' => array (

+ 4 - 0
modules/base/text/template/form_ghost_template.html

@@ -29,4 +29,8 @@
     $(".bx-base-general-icon-{file_id}").bind('dragstart', function(){
         return false; 
     });
+
+    // select first image as a thumb by default
+    if (1 == $('input[name="__name_thumb__[]"]').length)
+        $('input[name="__name_thumb__[]"]').attr('checked', true);
 </script>