Skip to content

Commit de0c848

Browse files
Merge pull request #101 from Adtrex/master
add transformation documention
2 parents 20a133b + 553b40e commit de0c848

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

README.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,90 @@ $page = Page::find(2);
210210
$page->detachMedia($file) // Example of $file is $request->file('file');
211211
```
212212

213+
## **Add Transformation to Uploads Using AttachMedia Method**:
214+
215+
```php
216+
217+
/**
218+
* How to resize an image to a specific width and height, and crop it using 'fill' mode
219+
*/
220+
221+
$options = [
222+
'transformation' => [
223+
[
224+
'width' => 200, // Desired width
225+
'height' => 200, // Desired height
226+
'crop' => 'fill', // Crop mode (you can change this to 'fit' or other modes)
227+
],
228+
],
229+
]
230+
231+
$page->attachMedia($file, $options); // Example of $file is $request->file('file');
232+
233+
/**
234+
* How to crop an image to a specific width and height.
235+
*/
236+
237+
$options = [
238+
'transformation' => [
239+
[
240+
'width' => 200, // Desired width
241+
'height' => 200, // Desired height
242+
'crop' => 'crop', // Crop mode
243+
],
244+
],
245+
]
246+
247+
$page->attachMedia($file, $options); // Example of $file is $request->file('file');
248+
249+
/**
250+
* How to rotate an image by a specific degree.
251+
*/
252+
253+
$options = [
254+
'transformation' => [
255+
[
256+
'angle' => 45, // Rotation angle
257+
],
258+
],
259+
]
260+
261+
$page->attachMedia($file, $options); // Example of $file is $request->file('file');
262+
263+
/**
264+
* How to apply a filter to an image.
265+
*/
266+
267+
$options = [
268+
'transformation' => [
269+
[
270+
'effect' => 'grayscale', // Filter effect
271+
],
272+
],
273+
]
274+
275+
$page->attachMedia($file, $options); // Example of $file is $request->file('file');
276+
277+
/**
278+
* How to overlay text on an image.
279+
*/
280+
281+
$options = [
282+
'transformation' => [
283+
[
284+
'overlay' => [
285+
'font_family' => 'arial',
286+
'font_size' => 24,
287+
'text' => 'Hello World',
288+
],
289+
],
290+
],
291+
]
292+
293+
$page->attachMedia($file, $options); // Example of $file is $request->file('file');
294+
295+
```
296+
213297
## **Upload Files Via An Upload Widget**:
214298

215299
Use the `x-cld-upload-button` Blade upload button component that ships with this Package like so:

0 commit comments

Comments
 (0)