Comments (6)
The getMedia
-method has second, yet undocumented, parameter with which you can filter the results.
You can use it in this way:
$images = $subject->getMedia('images, ['id' => $mediaId]);
Keep in mind that when filtering on id the result is a collection with one or zero elements. If you need a more convenient way to get a media object from a collection by it's id feel free to submit a pull request.
I'll probably add some better filtering methods (use a callable instead of an array) in a future version of the package.
from laravel-medialibrary.
Yep, that for filtering on custom properties. Here is the code that does the actual filtering.
from laravel-medialibrary.
@freekmurze can you provide more details on the second parameter ['id' => $mediaId] is it custom property ?
from laravel-medialibrary.
This solution seams to only filter by custom_properties, Is there an easy way to retrieve by media ID or would you be open to a pull request?
from laravel-medialibrary.
I'd accept a good PR that adds a function to retrieve a specific media item to the package.
from laravel-medialibrary.
Im not sure it is a good PR but it is here
#419
from laravel-medialibrary.
Related Issues (20)
- Quality for webp not working HOT 2
- Livewire 3 Component: Multiple File Upload, not all previews display on edit. HOT 1
- Transparent Images (PNG) has black background when converted. HOT 7
- Media repository always returns an empty collection HOT 1
- Fit::Max resizing images to fill dimensions and painting background HOT 1
- hasMedia accept only array HOT 1
- No upgrade guide to `medialibrary-pro` v5
- Calling toHtml on Media model doesn't return alt, unless defined via attributes
- image V3: Conversions tilting (some) images from portrait to landscape
- Call to a member function getMedia() on null in FileAdder.php when try return media collection after upload file for not exists model
- Media collections are lazy loaded with `preventLazyLoading()` enabled HOT 2
- addMediaFromDisk Method not defined when used in Queue Job
- When regenerating responsive images get wiped out.
- Broken link in UPGRADING,md, no instructions available for how to update conversions to new syntax. HOT 2
- Upgrade to 11: Custom optimizer ignored HOT 4
- Publishing the views is not working or not documented HOT 3
- php 8.3.4 + laravel-medialibrary 11.4.5: opcache+jit error: Only arrays and Traversables can be unpacked HOT 2
- Intervention\Image\Exception\NotReadableException: Unsupported image type application/x-empty. HOT 2
- Error when using withManipulations in combination with enumerations HOT 2
- Imagick driver works super slow with v11 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-medialibrary.