Skip to content

Commit

Permalink
fix: update image size validation to correctly be 2mb instead of appr…
Browse files Browse the repository at this point in the history
…ox. 20mb & add validation to admin reuploads
  • Loading branch information
ScuffedNewt committed May 19, 2024
1 parent ccba4c4 commit c08496f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ public function getImageReupload($id) {
* @return \Illuminate\Http\RedirectResponse
*/
public function postImageReupload(Request $request, CharacterManager $service, $id) {
$request->validate(['image' => CharacterImage::$createRules['image'], 'thumbnail' => CharacterImage::$createRules['thumbnail']]);
$data = $request->only(['image', 'thumbnail', 'x0', 'x1', 'y0', 'y1', 'use_cropper']);
$image = CharacterImage::find($id);
if (!$image) {
Expand Down
8 changes: 4 additions & 4 deletions app/Models/Character/Character.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ class Character extends Model {
'slug' => 'required|alpha_dash',
'description' => 'nullable',
'sale_value' => 'nullable',
'image' => 'required|mimes:jpeg,jpg,gif,png|max:20000',
'thumbnail' => 'nullable|mimes:jpeg,jpg,gif,png|max:20000',
'image' => 'required|mimes:jpeg,jpg,gif,png|max:2048',
'thumbnail' => 'nullable|mimes:jpeg,jpg,gif,png|max:2048',
'owner_url' => 'url|nullable',
];

Expand Down Expand Up @@ -109,8 +109,8 @@ class Character extends Model {
'description' => 'nullable',
'sale_value' => 'nullable',
'name' => 'required',
'image' => 'nullable|mimes:jpeg,gif,png|max:20000',
'thumbnail' => 'nullable|mimes:jpeg,gif,png|max:20000',
'image' => 'nullable|mimes:jpeg,gif,png|max:2048',
'thumbnail' => 'nullable|mimes:jpeg,gif,png|max:2048',
];

/**********************************************************************************************
Expand Down
6 changes: 3 additions & 3 deletions app/Models/Character/CharacterImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ class CharacterImage extends Model {
public static $createRules = [
'species_id' => 'required',
'rarity_id' => 'required',
'image' => 'required|mimes:jpeg,jpg,gif,png,webp|max:20000',
'thumbnail' => 'nullable|mimes:jpeg,jpg,gif,png,webp|max:20000',
'image' => 'required|mimes:jpeg,jpg,gif,png,webp|max:2048',
'thumbnail' => 'nullable|mimes:jpeg,jpg,gif,png,webp|max:2048',
];

/**
Expand Down Expand Up @@ -225,7 +225,7 @@ public function getFullsizeUrlAttribute() {
/**
* Gets the file name of the model's fullsize image.
*
* @param user
* @param User
* @param mixed|null $user
*
* @return string
Expand Down

0 comments on commit c08496f

Please sign in to comment.