Skip to content

Commit 4cd4f0e

Browse files
committed
Merge branch 'editor-update'
# Conflicts: # README.md
2 parents a5bcee9 + 57ee852 commit 4cd4f0e

File tree

5 files changed

+48
-15
lines changed

5 files changed

+48
-15
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ After upgraded to latest version follows these steps:
147147
## Version History
148148
- 7.2.1 - adds reading progress bar feature (if you upgrade, re-publish config file and view files)
149149
- 7.2.0 - adds sub-category functionality to blog
150+
- 7.1.8 - ability to remove images from posts (this feature does not work for old posts)
151+
- 7.1.7 - updates CKEditor
150152
- 7.1.5 - minor fix for recent posts
151153
- 7.1.4 - updates fulltext search package which solves the search issue
152154
- 7.1.2 - shows categories on blog home page - minor fix (if you upgrade try to re-publish view files)

src/Controllers/BlogEtcAdminController.php

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,41 @@ public function update_post(UpdateBlogEtcPostRequest $request, $blogPostId)
126126

127127
}
128128

129+
public function remove_photo($postSlug)
130+
{
131+
$post = BlogEtcPost::where("slug", $postSlug)->firstOrFail();
132+
133+
$path = public_path('/' . config("blogetc.blog_upload_dir"));
134+
if (!$this->checked_blog_image_dir_is_writable) {
135+
if (!is_writable($path)) {
136+
throw new \RuntimeException("Image destination path is not writable ($path)");
137+
}
138+
}
139+
140+
$destinationPath = $this->image_destination_path();
141+
142+
if (file_exists($destinationPath.'/'.$post->image_large)) {
143+
unlink($destinationPath.'/'.$post->image_large);
144+
}
145+
146+
if (file_exists($destinationPath.'/'.$post->image_medium)) {
147+
unlink($destinationPath.'/'.$post->image_medium);
148+
}
149+
150+
if (file_exists($destinationPath.'/'.$post->image_thumbnail)) {
151+
unlink($destinationPath.'/'.$post->image_thumbnail);
152+
}
153+
154+
$post->image_large = null;
155+
$post->image_medium = null;
156+
$post->image_thumbnail = null;
157+
$post->save();
158+
159+
Helpers::flash_message("Photo removed");
160+
161+
return redirect($post->edit_url());
162+
}
163+
129164
/**
130165
* Delete a post
131166
*
@@ -176,14 +211,13 @@ protected function processUploadedImages(BaseRequestInterface $request, BlogEtcP
176211
// this image size is enabled, and
177212
// we have an uploaded image that we can use
178213

179-
$uploaded_image = $this->UploadAndResize($new_blog_post, $new_blog_post->title, $image_size_details, $photo);
214+
$uploaded_image = $this->UploadAndResize($new_blog_post, $new_blog_post->slug, $image_size_details, $photo);
180215

181216
$new_blog_post->$size = $uploaded_image['filename'];
182217
$uploaded_image_details[$size] = $uploaded_image;
183218
}
184219
}
185220

186-
187221
// store the image upload.
188222
// todo: link this to the blogetc_post row.
189223
if (count(array_filter($uploaded_image_details))>0) {
@@ -192,9 +226,5 @@ protected function processUploadedImages(BaseRequestInterface $request, BlogEtcP
192226
'uploaded_images' => $uploaded_image_details,
193227
]);
194228
}
195-
196-
197229
}
198-
199-
200230
}

src/Views/blogetc_admin/layouts/admin_layout.blade.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,7 @@
121121

122122

123123
@if( config("blogetc.use_wysiwyg") && config("blogetc.echo_html") && (in_array( \Request::route()->getName() ,[ 'blogetc.admin.create_post' , 'blogetc.admin.edit_post' ])))
124-
<script src="https://cdn.ckeditor.com/4.10.0/standard/ckeditor.js"
125-
integrity="sha384-BpuqJd0Xizmp9PSp/NTwb/RSBCHK+rVdGWTrwcepj1ADQjNYPWT2GDfnfAr6/5dn"
126-
crossorigin="anonymous"></script>
124+
<script src="//cdn.ckeditor.com/4.14.1/full/ckeditor.js"></script>
127125
<script>
128126
if( typeof(CKEDITOR) !== "undefined" ) {
129127
CKEDITOR.replace('post_body');

src/Views/blogetc_admin/posts/form.blade.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,12 @@
8484
name='post_body'>{{old("post_body",$post->post_body)}}</textarea>
8585

8686

87-
<div class='alert alert-danger'>
88-
Please note that any HTML (including any JS code) that is entered here will be
89-
echoed (without escaping)
87+
<div class='alert alert-warning'>
88+
If you want to add HTML content to be rendered, click source button at top left, and then paste your HTML snippet. (Youtube iFrames)
9089
</div>
9190
</div>
9291

9392

94-
95-
9693
@if(config("blogetc.use_custom_view_files",true))
9794
<div class="form-group">
9895
<label for="blog_use_view_file">Custom View File</label>
@@ -162,7 +159,9 @@
162159
<input class="form-control" type="file" name="{{$size_key}}" id="blog_{{$size_key}}"
163160
aria-describedby="blog_{{$size_key}}_help">
164161

165-
162+
@if($post->has_image($size_info['basic_key']))
163+
<a style="color: darkred" href="{{route("blogetc.admin.remove_photo", $post->slug)}}">Remove Image</a>
164+
@endif
166165
</div>
167166
@endforeach
168167

src/routes.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@
6363
'BlogEtcAdminController@update_post')
6464
->name('blogetc.admin.update_post');
6565

66+
//Removes post's photo
67+
Route::get('/remove_photo/{slug}',
68+
'BlogEtcAdminController@remove_photo')
69+
->name('blogetc.admin.remove_photo');
6670

6771
Route::group(['prefix' => "image_uploads",], function () {
6872

0 commit comments

Comments
 (0)