|
1 |
| - <div class="form-group image" data-preview="#{{ $field['name'] }}" data-aspectRatio="{{ $field['aspect_ratio'] }}" data-crop="{{ $field['crop'] }}"> |
| 1 | + <div class="form-group col-md-12 image" data-preview="#{{ $field['name'] }}" data-aspectRatio="{{ $field['aspect_ratio'] }}" data-crop="{{ $field['crop'] }}"> |
2 | 2 | <div>
|
3 | 3 | <label>{!! $field['label'] !!}</label>
|
4 | 4 | </div>
|
5 | 5 | <!-- Wrap the image or canvas element with a block element (container) -->
|
6 | 6 | <div class="row">
|
7 | 7 | <div class="col-sm-6" style="margin-bottom: 20px;">
|
8 |
| - <img id="mainImage" src="{{ isset($field['src']) ? $entry->where('id', $entry->id)->first()->{$field['src']}() : $field['value'] }}"> |
| 8 | + <img id="mainImage" src="{{ isset($field['src']) ? $entry->where('id', $entry->id)->first()->{$field['src']}() : (isset($field['value']))?$field['value']:'' }}"> |
9 | 9 | </div>
|
10 | 10 | @if($field['crop'])
|
11 | 11 | <div class="col-sm-3">
|
|
14 | 14 | <img src="" style="display: block; min-width: 0px !important; min-height: 0px !important; max-width: none !important; max-height: none !important; margin-left: -32.875px; margin-top: -18.4922px; transform: none;">
|
15 | 15 | </div>
|
16 | 16 | </div>
|
17 |
| - </div> |
| 17 | + </div> |
18 | 18 | @endif
|
19 | 19 | <input type="hidden" id="hiddenFilename" name="{{ $field['filename'] }}" value="">
|
20 | 20 | </div>
|
|
28 | 28 | <button class="btn btn-default" id="rotateRight" type="button" style="display: none;">Rotate Right</button>
|
29 | 29 | <button class="btn btn-default" id="zoomIn" type="button" style="display: none;">Zoom In</button>
|
30 | 30 | <button class="btn btn-default" id="zoomOut" type="button" style="display: none;">Zoom Out</button>
|
31 |
| - <button class="btn btn-warning" id="reset" type="button" style="display: none;">Reset</button> |
| 31 | + <button class="btn btn-warning" id="reset" type="button" style="display: none;">Reset</button> |
32 | 32 | @endif
|
33 | 33 | <button class="btn btn-danger" id="remove" type="button">Remove</button>
|
34 | 34 | </div>
|
|
131 | 131 |
|
132 | 132 | // Only initialize cropper plugin if crop is set to true
|
133 | 133 | if(crop){
|
134 |
| - |
| 134 | +
|
135 | 135 | $remove.click(function() {
|
136 | 136 | $mainImage.cropper("destroy");
|
137 | 137 | $mainImage.attr('src','');
|
|
145 | 145 | $zoomOut.hide();
|
146 | 146 | $reset.hide();
|
147 | 147 | $remove.hide();
|
148 |
| - }); |
149 |
| - } else { |
150 |
| - |
| 148 | + }); |
| 149 | + } else { |
| 150 | +
|
151 | 151 | $(this).find("#remove").click(function() {
|
152 | 152 | $mainImage.attr('src','');
|
153 | 153 | $hiddenImage.val('');
|
154 |
| - $hiddenFilename.val('removed'); |
| 154 | + $hiddenFilename.val('removed'); |
155 | 155 | $remove.hide();
|
156 | 156 | });
|
157 | 157 | }
|
158 |
| - |
| 158 | +
|
159 | 159 | //Set hiddenFilename field to 'removed' if image has been removed.
|
160 | 160 | //Otherwise hiddenFilename will be null if no changes have been made.
|
161 | 161 |
|
|
168 | 168 | return;
|
169 | 169 | }
|
170 | 170 | file = files[0];
|
171 |
| - |
| 171 | +
|
172 | 172 | if (/^image\/\w+$/.test(file.type)) {
|
173 | 173 | $hiddenFilename.val(file.name);
|
174 | 174 | fileReader.readAsDataURL(file);
|
|
203 | 203 | $zoomOut.show();
|
204 | 204 | $reset.show();
|
205 | 205 | $remove.show();
|
206 |
| - |
207 |
| - } else { |
| 206 | +
|
| 207 | + } else { |
208 | 208 | $mainImage.attr('src',this.result);
|
209 | 209 | $hiddenImage.val(this.result);
|
210 | 210 | $remove.show();
|
211 |
| - } |
| 211 | + } |
212 | 212 | };
|
213 | 213 | } else {
|
214 | 214 | alert("Please choose an image file.");
|
215 | 215 | }
|
216 | 216 | });
|
217 |
| - |
| 217 | +
|
218 | 218 | });
|
219 | 219 | });
|
220 | 220 | </script>
|
|
0 commit comments