Skip to content

Conversation

@shaoshiva
Copy link
Contributor

Adds a new trait HasMediaTrait that can be used instead of the one provided by spatie/medialibrary to implement some additional features and work with medias from translatable attribute.

For example with this trait you can easily configure and use crop and fit max conversions on your model :

protected $mediaConversionsCrop = [
      'background' => [
            'large' => [1440, 810],
            'medium' => [1080, 608],
            'small' => [768, 432],
      ],
];

protected $mediaConversionsFitMax = [
      'background' => [
            'large' => [877, 900],
            'medium' => [670, 687],
            'small' => [580, 594],
      ],
];

public function backgroundFullCropUrl()
{
    return $this->getAttributeMediaCropUrl('background', 'large', true);
}

public function backgroundFullFitMaxUrl()
{
    return $this->getAttributeMediaFitMaxUrl('background', 'large', true);
}

*
* @var array
*/
// protected $mediaConversionsCrop = [
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We find already this information in the readme file. If it is intended as documentation I would put this within the trait phpdoc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants