Skip to content

Commit bb3d72a

Browse files
committed
base64_image field type small fix
1 parent 79d15a2 commit bb3d72a

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/resources/views/fields/base64_image.blade.php

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
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'] }}">
22
<div>
33
<label>{!! $field['label'] !!}</label>
44
</div>
55
<!-- Wrap the image or canvas element with a block element (container) -->
66
<div class="row">
77
<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']:'' }}">
99
</div>
1010
@if($field['crop'])
1111
<div class="col-sm-3">
@@ -14,7 +14,7 @@
1414
<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;">
1515
</div>
1616
</div>
17-
</div>
17+
</div>
1818
@endif
1919
<input type="hidden" id="hiddenFilename" name="{{ $field['filename'] }}" value="">
2020
</div>
@@ -28,7 +28,7 @@
2828
<button class="btn btn-default" id="rotateRight" type="button" style="display: none;">Rotate Right</button>
2929
<button class="btn btn-default" id="zoomIn" type="button" style="display: none;">Zoom In</button>
3030
<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>
3232
@endif
3333
<button class="btn btn-danger" id="remove" type="button">Remove</button>
3434
</div>
@@ -131,7 +131,7 @@
131131
132132
// Only initialize cropper plugin if crop is set to true
133133
if(crop){
134-
134+
135135
$remove.click(function() {
136136
$mainImage.cropper("destroy");
137137
$mainImage.attr('src','');
@@ -145,17 +145,17 @@
145145
$zoomOut.hide();
146146
$reset.hide();
147147
$remove.hide();
148-
});
149-
} else {
150-
148+
});
149+
} else {
150+
151151
$(this).find("#remove").click(function() {
152152
$mainImage.attr('src','');
153153
$hiddenImage.val('');
154-
$hiddenFilename.val('removed');
154+
$hiddenFilename.val('removed');
155155
$remove.hide();
156156
});
157157
}
158-
158+
159159
//Set hiddenFilename field to 'removed' if image has been removed.
160160
//Otherwise hiddenFilename will be null if no changes have been made.
161161
@@ -168,7 +168,7 @@
168168
return;
169169
}
170170
file = files[0];
171-
171+
172172
if (/^image\/\w+$/.test(file.type)) {
173173
$hiddenFilename.val(file.name);
174174
fileReader.readAsDataURL(file);
@@ -203,18 +203,18 @@
203203
$zoomOut.show();
204204
$reset.show();
205205
$remove.show();
206-
207-
} else {
206+
207+
} else {
208208
$mainImage.attr('src',this.result);
209209
$hiddenImage.val(this.result);
210210
$remove.show();
211-
}
211+
}
212212
};
213213
} else {
214214
alert("Please choose an image file.");
215215
}
216216
});
217-
217+
218218
});
219219
});
220220
</script>

0 commit comments

Comments
 (0)