Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HasMediaTrait with additional features (conversions, translatable...) #41

Open
wants to merge 2 commits into
base: 0.3
Choose a base branch
from

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.

1 participant