Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze authored and github-actions[bot] committed Dec 8, 2023
1 parent 9e3052e commit b65a3e0
Show file tree
Hide file tree
Showing 71 changed files with 255 additions and 248 deletions.
2 changes: 1 addition & 1 deletion config/media-library.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
/*
* When enabled, media collections will be serialised using the default
* laravel model serialization behaviour.
*
*
* Keep this option disabled if using Media Library Pro components (https://medialibrary.pro)
*/
'use_default_collection_serialization' => false,
Expand Down
2 changes: 1 addition & 1 deletion src/Conversions/Commands/RegenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function getMediaToBeRegenerated(): Collection
// Get this arg first as it can also be passed to the greater-than-id branch
$modelType = $this->argument('modelType');

$startingFromId = (int)$this->option('starting-from-id');
$startingFromId = (int) $this->option('starting-from-id');
if ($startingFromId !== 0) {
$excludeStartingId = (bool) $this->option('exclude-starting-id') ?: false;

Expand Down
2 changes: 1 addition & 1 deletion src/Conversions/FileManipulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function performConversions(

$copiedOriginalFile = app(Filesystem::class)->copyFromMediaLibrary(
$media,
$temporaryDirectory->path(Str::random(32) . '.' . $media->extension)
$temporaryDirectory->path(Str::random(32).'.'.$media->extension)
);

$conversions
Expand Down
105 changes: 71 additions & 34 deletions src/Conversions/FromImagePackage/OldManipulations.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,58 +9,95 @@
class OldManipulations
{
public const CROP_TOP_LEFT = 'crop-top-left';

public const CROP_TOP = 'crop-top';

public const CROP_TOP_RIGHT = 'crop-top-right';

public const CROP_LEFT = 'crop-left';

public const CROP_CENTER = 'crop-center';

public const CROP_RIGHT = 'crop-right';

public const CROP_BOTTOM_LEFT = 'crop-bottom-left';

public const CROP_BOTTOM = 'crop-bottom';

public const CROP_BOTTOM_RIGHT = 'crop-bottom-right';

public const ORIENTATION_AUTO = 'auto';

public const ORIENTATION_0 = 0;

public const ORIENTATION_90 = 90;

public const ORIENTATION_180 = 180;

public const ORIENTATION_270 = 270;

public const FLIP_HORIZONTALLY = 'h';

public const FLIP_VERTICALLY = 'v';

public const FLIP_BOTH = 'both';

public const FIT_CONTAIN = 'contain';

public const FIT_MAX = 'max';

public const FIT_FILL = 'fill';

public const FIT_FILL_MAX = 'fill-max';

public const FIT_STRETCH = 'stretch';

public const FIT_CROP = 'crop';

public const BORDER_OVERLAY = 'overlay';

public const BORDER_SHRINK = 'shrink';

public const BORDER_EXPAND = 'expand';

public const FORMAT_JPG = 'jpg';

public const FORMAT_PJPG = 'pjpg';

public const FORMAT_PNG = 'png';

public const FORMAT_GIF = 'gif';

public const FORMAT_WEBP = 'webp';

public const FORMAT_AVIF = 'avif';

public const FORMAT_TIFF = 'tiff';

public const FILTER_GREYSCALE = 'greyscale';

public const FILTER_SEPIA = 'sepia';

public const UNIT_PIXELS = 'px';

public const UNIT_PERCENT = '%';

public const POSITION_TOP_LEFT = 'top-left';

public const POSITION_TOP = 'top';

public const POSITION_TOP_RIGHT = 'top-right';

public const POSITION_LEFT = 'left';

public const POSITION_CENTER = 'center';

public const POSITION_RIGHT = 'right';

public const POSITION_BOTTOM_LEFT = 'bottom-left';

public const POSITION_BOTTOM = 'bottom';

public const POSITION_BOTTOM_RIGHT = 'bottom-right';

protected ManipulationSequence $manipulationSequence;
Expand Down Expand Up @@ -133,8 +170,8 @@ public function crop(string $cropMethod, int $width, int $height): static
}

/**
* @param int $focalX Crop center X in percent
* @param int $focalY Crop center Y in percent
* @param int $focalX Crop center X in percent
* @param int $focalY Crop center Y in percent
*
* @throws InvalidManipulation
*/
Expand Down Expand Up @@ -175,7 +212,7 @@ public function width(int $width): static
throw InvalidManipulation::invalidWidth($width);
}

return $this->addManipulation('width', (string)$width);
return $this->addManipulation('width', (string) $width);
}

/**
Expand All @@ -187,7 +224,7 @@ public function height(int $height): static
throw InvalidManipulation::invalidHeight($height);
}

return $this->addManipulation('height', (string)$height);
return $this->addManipulation('height', (string) $height);
}

/**
Expand Down Expand Up @@ -219,7 +256,7 @@ public function fit(string $fitMethod, ?int $width = null, ?int $height = null):
}

/**
* @param int $ratio A value between 1 and 8
* @param int $ratio A value between 1 and 8
*
* @throws InvalidManipulation
*/
Expand All @@ -229,11 +266,11 @@ public function devicePixelRatio(int $ratio): static
throw InvalidManipulation::valueNotInRange('ratio', $ratio, 1, 8);
}

return $this->addManipulation('devicePixelRatio', (string)$ratio);
return $this->addManipulation('devicePixelRatio', (string) $ratio);
}

/**
* @param int $brightness A value between -100 and 100
* @param int $brightness A value between -100 and 100
*
* @throws InvalidManipulation
*/
Expand All @@ -243,11 +280,11 @@ public function brightness(int $brightness): static
throw InvalidManipulation::valueNotInRange('brightness', $brightness, -100, 100);
}

return $this->addManipulation('brightness', (string)$brightness);
return $this->addManipulation('brightness', (string) $brightness);
}

/**
* @param float $gamma A value between 0.01 and 9.99
* @param float $gamma A value between 0.01 and 9.99
*
* @throws InvalidManipulation
*/
Expand All @@ -257,11 +294,11 @@ public function gamma(float $gamma): static
throw InvalidManipulation::valueNotInRange('gamma', $gamma, 0.01, 9.00);
}

return $this->addManipulation('gamma', (string)$gamma);
return $this->addManipulation('gamma', (string) $gamma);
}

/**
* @param int $contrast A value between -100 and 100
* @param int $contrast A value between -100 and 100
*
* @throws InvalidManipulation
*/
Expand All @@ -271,11 +308,11 @@ public function contrast(int $contrast): static
throw InvalidManipulation::valueNotInRange('contrast', $contrast, -100, 100);
}

return $this->addManipulation('contrast', (string)$contrast);
return $this->addManipulation('contrast', (string) $contrast);
}

/**
* @param int $sharpen A value between 0 and 100
* @param int $sharpen A value between 0 and 100
*
* @throws InvalidManipulation
*/
Expand All @@ -285,11 +322,11 @@ public function sharpen(int $sharpen): static
throw InvalidManipulation::valueNotInRange('sharpen', $sharpen, 0, 100);
}

return $this->addManipulation('sharpen', (string)$sharpen);
return $this->addManipulation('sharpen', (string) $sharpen);
}

/**
* @param int $blur A value between 0 and 100
* @param int $blur A value between 0 and 100
*
* @throws InvalidManipulation
*/
Expand All @@ -299,11 +336,11 @@ public function blur(int $blur): static
throw InvalidManipulation::valueNotInRange('blur', $blur, 0, 100);
}

return $this->addManipulation('blur', (string)$blur);
return $this->addManipulation('blur', (string) $blur);
}

/**
* @param int $pixelate A value between 0 and 1000
* @param int $pixelate A value between 0 and 1000
*
* @throws InvalidManipulation
*/
Expand All @@ -313,7 +350,7 @@ public function pixelate(int $pixelate): static
throw InvalidManipulation::valueNotInRange('pixelate', $pixelate, 0, 1000);
}

return $this->addManipulation('pixelate', (string)$pixelate);
return $this->addManipulation('pixelate', (string) $pixelate);
}

/**
Expand Down Expand Up @@ -366,7 +403,7 @@ public function quality(int $quality): static
throw InvalidManipulation::valueNotInRange('quality', $quality, 0, 100);
}

return $this->addManipulation('quality', (string)$quality);
return $this->addManipulation('quality', (string) $quality);
}

/**
Expand Down Expand Up @@ -416,29 +453,29 @@ public function watermark(string $filePath): static
}

/**
* @param int $width The width of the watermark in pixels (default) or percent.
* @param string $unit The unit of the `$width` parameter. Use `Manipulations::UNIT_PERCENT` or `Manipulations::UNIT_PIXELS`.
* @param int $width The width of the watermark in pixels (default) or percent.
* @param string $unit The unit of the `$width` parameter. Use `Manipulations::UNIT_PERCENT` or `Manipulations::UNIT_PIXELS`.
*/
public function watermarkWidth(int $width, string $unit = 'px'): static
{
$width = ($unit === static::UNIT_PERCENT ? $width.'w' : $width);

return $this->addManipulation('watermarkWidth', (string)$width);
return $this->addManipulation('watermarkWidth', (string) $width);
}

/**
* @param int $height The height of the watermark in pixels (default) or percent.
* @param string $unit The unit of the `$height` parameter. Use `Manipulations::UNIT_PERCENT` or `Manipulations::UNIT_PIXELS`.
* @param int $height The height of the watermark in pixels (default) or percent.
* @param string $unit The unit of the `$height` parameter. Use `Manipulations::UNIT_PERCENT` or `Manipulations::UNIT_PIXELS`.
*/
public function watermarkHeight(int $height, string $unit = 'px'): static
{
$height = ($unit === static::UNIT_PERCENT ? $height.'h' : $height);

return $this->addManipulation('watermarkHeight', (string)$height);
return $this->addManipulation('watermarkHeight', (string) $height);
}

/**
* @param string $fitMethod How is the watermark fitted into the watermarkWidth and watermarkHeight properties.
* @param string $fitMethod How is the watermark fitted into the watermarkWidth and watermarkHeight properties.
*
* @throws InvalidManipulation
*/
Expand All @@ -456,19 +493,19 @@ public function watermarkFit(string $fitMethod): static
}

/**
* @param int $xPadding How far is the watermark placed from the left and right edges of the image.
* @param int|null $yPadding How far is the watermark placed from the top and bottom edges of the image.
* @param string $unit Unit of the padding values. Use `Manipulations::UNIT_PERCENT` or `Manipulations::UNIT_PIXELS`.
* @param int $xPadding How far is the watermark placed from the left and right edges of the image.
* @param int|null $yPadding How far is the watermark placed from the top and bottom edges of the image.
* @param string $unit Unit of the padding values. Use `Manipulations::UNIT_PERCENT` or `Manipulations::UNIT_PIXELS`.
*/
public function watermarkPadding(int $xPadding, int $yPadding = null, string $unit = 'px'): static
public function watermarkPadding(int $xPadding, ?int $yPadding = null, string $unit = 'px'): static
{
$yPadding = $yPadding ?? $xPadding;

$xPadding = ($unit === static::UNIT_PERCENT ? $xPadding.'w' : $xPadding);
$yPadding = ($unit === static::UNIT_PERCENT ? $yPadding.'h' : $yPadding);

$this->addManipulation('watermarkPaddingX', (string)$xPadding);
$this->addManipulation('watermarkPaddingY', (string)$yPadding);
$this->addManipulation('watermarkPaddingX', (string) $xPadding);
$this->addManipulation('watermarkPaddingY', (string) $yPadding);

return $this;
}
Expand All @@ -492,7 +529,7 @@ public function watermarkPosition(string $position): static
/**
* Sets the opacity of the watermark. Only works with the `imagick` driver.
*
* @param int $opacity A value between 0 and 100.
* @param int $opacity A value between 0 and 100.
*
* @throws InvalidManipulation
*/
Expand All @@ -502,7 +539,7 @@ public function watermarkOpacity(int $opacity): static
throw InvalidManipulation::valueNotInRange('opacity', $opacity, 0, 100);
}

return $this->addManipulation('watermarkOpacity', (string)$opacity);
return $this->addManipulation('watermarkOpacity', (string) $opacity);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Conversions/ImageGenerators/Avif.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class Avif extends ImageGenerator
{
public function convert(string $file, Conversion $conversion = null): string
public function convert(string $file, ?Conversion $conversion = null): string
{
$pathToImageFile = pathinfo($file, PATHINFO_DIRNAME).'/'.pathinfo($file, PATHINFO_FILENAME).'.png';

Expand Down
2 changes: 1 addition & 1 deletion src/Conversions/ImageGenerators/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class Image extends ImageGenerator
{
public function convert(string $path, Conversion $conversion = null): string
public function convert(string $path, ?Conversion $conversion = null): string
{
return $path;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Conversions/ImageGenerators/ImageGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ abstract class ImageGenerator
/*
* This function should return a path to an image representation of the given file.
*/
abstract public function convert(string $file, Conversion $conversion = null): ?string;
abstract public function convert(string $file, ?Conversion $conversion = null): ?string;

public function canConvert(Media $media): bool
{
Expand Down
2 changes: 1 addition & 1 deletion src/Conversions/ImageGenerators/Pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class Pdf extends ImageGenerator
{
public function convert(string $file, Conversion $conversion = null): string
public function convert(string $file, ?Conversion $conversion = null): string
{
$imageFile = pathinfo($file, PATHINFO_DIRNAME).'/'.pathinfo($file, PATHINFO_FILENAME).'.jpg';

Expand Down
2 changes: 1 addition & 1 deletion src/Conversions/ImageGenerators/Svg.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class Svg extends ImageGenerator
{
public function convert(string $file, Conversion $conversion = null): string
public function convert(string $file, ?Conversion $conversion = null): string
{
$imageFile = pathinfo($file, PATHINFO_DIRNAME).'/'.pathinfo($file, PATHINFO_FILENAME).'.jpg';

Expand Down
2 changes: 1 addition & 1 deletion src/Conversions/ImageGenerators/Video.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class Video extends ImageGenerator
{
public function convert(string $file, Conversion $conversion = null): ?string
public function convert(string $file, ?Conversion $conversion = null): ?string
{
$ffmpeg = FFMpeg::create([
'ffmpeg.binaries' => config('media-library.ffmpeg_path'),
Expand Down
Loading

0 comments on commit b65a3e0

Please sign in to comment.