Commit 7f0ace2faf5681291e1afaf492c89871bd1a17c4
1 parent
b9a5d332
full commit
Showing
1 changed file
with
23 additions
and
1 deletions
Show diff stats
behaviors/SaveImgBehavior.php
@@ -43,7 +43,7 @@ | @@ -43,7 +43,7 @@ | ||
43 | if($this->isLanguage) { | 43 | if($this->isLanguage) { |
44 | $name = '[' . $this->owner->language_id . ']' . $name; | 44 | $name = '[' . $this->owner->language_id . ']' . $name; |
45 | } | 45 | } |
46 | - | 46 | + |
47 | $image = UploadedFile::getInstance($this->owner, $name); | 47 | $image = UploadedFile::getInstance($this->owner, $name); |
48 | 48 | ||
49 | if(empty( $image ) && $event->name == ActiveRecord::EVENT_BEFORE_UPDATE) { | 49 | if(empty( $image ) && $event->name == ActiveRecord::EVENT_BEFORE_UPDATE) { |
@@ -98,4 +98,26 @@ | @@ -98,4 +98,26 @@ | ||
98 | $directory = $fieldset[ 'directory' ]; | 98 | $directory = $fieldset[ 'directory' ]; |
99 | return empty( $this->owner->$name ) ? ( $dummy ? $this->dummy_path : null ) : '/storage/' . $directory . '/' . $this->owner->$name; | 99 | return empty( $this->owner->$name ) ? ( $dummy ? $this->dummy_path : null ) : '/storage/' . $directory . '/' . $this->owner->$name; |
100 | } | 100 | } |
101 | + | ||
102 | + /** | ||
103 | + * @param string $image | ||
104 | + * @return array | ||
105 | + */ | ||
106 | + public function getImagesConfig($image = 'image') { | ||
107 | + $op = []; | ||
108 | + if ($this->owner->$image) { | ||
109 | + | ||
110 | + $op[] = [ | ||
111 | + 'caption' => $this->owner->$image, | ||
112 | + 'url' => \yii\helpers\Url::to(['delimg', 'id' => $this->owner->primaryKey, 'field' =>$image ]), | ||
113 | + 'key' => $this->owner->primaryKey, | ||
114 | + 'extra' => [ | ||
115 | + 'id' => $this->owner->primaryKey, | ||
116 | + ], | ||
117 | + ]; | ||
118 | + | ||
119 | + } | ||
120 | + return $op; | ||
121 | + } | ||
122 | + | ||
101 | } | 123 | } |
102 | \ No newline at end of file | 124 | \ No newline at end of file |