@@ -85,7 +85,11 @@ public function imageUrl($field = null)
85
85
$ this ->uploadFieldOptions = $ this ->getUploadFieldOptions ($ this ->uploadFieldName );
86
86
87
87
// get the model attribute value
88
- $ attributeValue = $ this ->getOriginal ($ this ->uploadFieldName );
88
+ if (Arr::get ($ this ->uploadFieldOptions , 'update_database ' ,true )){
89
+ $ attributeValue = $ this ->getOriginal ($ this ->uploadFieldName );
90
+ }else {
91
+ $ attributeValue = $ this ->getFileUploadPath ($ field );
92
+ }
89
93
90
94
// check for placeholder defined in option
91
95
$ placeholderImage = Arr::get ($ this ->uploadFieldOptions , 'placeholder ' );
@@ -569,12 +573,19 @@ protected function saveImage($imageFile, $image)
569
573
*/
570
574
protected function updateModel ($ imagePath , $ imageFieldName )
571
575
{
572
- $ this ->attributes [$ imageFieldName ] = $ imagePath ;
573
-
574
- $ dispatcher = $ this ->getEventDispatcher ();
575
- self ::unsetEventDispatcher ();
576
- $ this ->save ();
577
- self ::setEventDispatcher ($ dispatcher );
576
+ // check if update_database = false (default: true)
577
+ $ imagesFields = $ this ->getDefinedUploadFields ();
578
+ $ actualField =Arr::get ($ imagesFields , $ imageFieldName );
579
+ $ updateAuthorized =Arr::get ($ actualField , 'update_database ' ,true );
580
+
581
+ // update model (if update_database=true or not set)
582
+ if ($ updateAuthorized ){
583
+ $ this ->attributes [$ imageFieldName ] = $ imagePath ;
584
+ $ dispatcher = $ this ->getEventDispatcher ();
585
+ self ::unsetEventDispatcher ();
586
+ $ this ->save ();
587
+ self ::setEventDispatcher ($ dispatcher );
588
+ }
578
589
}
579
590
580
591
/**
0 commit comments