Blog/Posts Image - Delete
Hello Bobby
At Posts, I don't see and option (X) to delete the Post Image. I searched on voyager's BREAD edit-add and Posts edit-add but don't see any options either. From my observation only voyager settings.index shows x on single-image.
How can I add a delete single-image logic for posts?
Thank you
Hey there!
Indeed that seems to be a limitation on the voyager side, I might submit a PR with a fix. But in the meantime, here is how you could fix that:
-
Create the following directory:
mkdir resources/views/vendor/voyager/posts -
Then copy the Posts edit bread from the vendor folder to that new posts directory that you've just created:
cp vendor/tcg/voyager/resources/views/posts/edit-add.blade.php resources/views/vendor/voyager/posts/
-
Then edit that file that you've just copied
resources/views/vendor/voyager/posts/edit-add.blade.php -
Then find the image div, it has this comment above it
<!-- ### IMAGE ### -->, it should be near line 233 and update the div to:
<!-- ### IMAGE ### -->
<div class="panel panel-bordered panel-primary">
<div class="panel-heading">
<h3 class="panel-title"><i class="icon wb-image"></i> {{ __('voyager::post.image') }}</h3>
<div class="panel-actions">
<a class="panel-action voyager-angle-down" data-toggle="panel-collapse" aria-hidden="true"></a>
</div>
</div>
<div class="panel-body form-group" data-field-name="image">
@if(isset($dataTypeContent->image))
<a href="#" class="voyager-x remove-single-image" style="position:absolute;"></a>
<img src="{{ filter_var($dataTypeContent->image, FILTER_VALIDATE_URL) ? $dataTypeContent->image : Voyager::image( $dataTypeContent->image ) }}" data-file-name="{{ $dataTypeContent->image }}" data-id="{{ $dataTypeContent->getKey() }}" style="width:100%" />
@endif
<input type="file" name="image" data-name="image">
</div>
</div>
That should fix the problem!
Let me know if you have any questions!
1
It worked as expected. Thank you for your help!!!
1
Awesome! Happy to hear that it is all working!
