Skip to content

Commit 81c1941

Browse files
authored
Merge branch 'master' into patch-1
2 parents ef695fb + 2dc18d8 commit 81c1941

File tree

11 files changed

+4117
-2088
lines changed

11 files changed

+4117
-2088
lines changed

CODE_OF_CONDUCT.md

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
We as members, contributors, and leaders pledge to make participation in our
6+
community a harassment-free experience for everyone, regardless of age, body
7+
size, visible or invisible disability, ethnicity, sex characteristics, gender
8+
identity and expression, level of experience, education, socio-economic status,
9+
nationality, personal appearance, race, religion, or sexual identity
10+
and orientation.
11+
12+
We pledge to act and interact in ways that contribute to an open, welcoming,
13+
diverse, inclusive, and healthy community.
14+
15+
## Our Standards
16+
17+
Examples of behavior that contributes to a positive environment for our
18+
community include:
19+
20+
* Demonstrating empathy and kindness toward other people
21+
* Being respectful of differing opinions, viewpoints, and experiences
22+
* Giving and gracefully accepting constructive feedback
23+
* Accepting responsibility and apologizing to those affected by our mistakes,
24+
and learning from the experience
25+
* Focusing on what is best not just for us as individuals, but for the
26+
overall community
27+
28+
Examples of unacceptable behavior include:
29+
30+
* The use of sexualized language or imagery, and sexual attention or
31+
advances of any kind
32+
* Trolling, insulting or derogatory comments, and personal or political attacks
33+
* Public or private harassment
34+
* Publishing others' private information, such as a physical or email
35+
address, without their explicit permission
36+
* Other conduct which could reasonably be considered inappropriate in a
37+
professional setting
38+
39+
## Enforcement Responsibilities
40+
41+
Community leaders are responsible for clarifying and enforcing our standards of
42+
acceptable behavior and will take appropriate and fair corrective action in
43+
response to any behavior that they deem inappropriate, threatening, offensive,
44+
or harmful.
45+
46+
Community leaders have the right and responsibility to remove, edit, or reject
47+
comments, commits, code, wiki edits, issues, and other contributions that are
48+
not aligned to this Code of Conduct, and will communicate reasons for moderation
49+
decisions when appropriate.
50+
51+
## Scope
52+
53+
This Code of Conduct applies within all community spaces, and also applies when
54+
an individual is officially representing the community in public spaces.
55+
Examples of representing our community include using an official e-mail address,
56+
posting via an official social media account, or acting as an appointed
57+
representative at an online or offline event.
58+
59+
## Enforcement
60+
61+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
62+
reported to the community leaders responsible for enforcement at
63+
64+
All complaints will be reviewed and investigated promptly and fairly.
65+
66+
All community leaders are obligated to respect the privacy and security of the
67+
reporter of any incident.
68+
69+
## Enforcement Guidelines
70+
71+
Community leaders will follow these Community Impact Guidelines in determining
72+
the consequences for any action they deem in violation of this Code of Conduct:
73+
74+
### 1. Correction
75+
76+
**Community Impact**: Use of inappropriate language or other behavior deemed
77+
unprofessional or unwelcome in the community.
78+
79+
**Consequence**: A private, written warning from community leaders, providing
80+
clarity around the nature of the violation and an explanation of why the
81+
behavior was inappropriate. A public apology may be requested.
82+
83+
### 2. Warning
84+
85+
**Community Impact**: A violation through a single incident or series
86+
of actions.
87+
88+
**Consequence**: A warning with consequences for continued behavior. No
89+
interaction with the people involved, including unsolicited interaction with
90+
those enforcing the Code of Conduct, for a specified period of time. This
91+
includes avoiding interactions in community spaces as well as external channels
92+
like social media. Violating these terms may lead to a temporary or
93+
permanent ban.
94+
95+
### 3. Temporary Ban
96+
97+
**Community Impact**: A serious violation of community standards, including
98+
sustained inappropriate behavior.
99+
100+
**Consequence**: A temporary ban from any sort of interaction or public
101+
communication with the community for a specified period of time. No public or
102+
private interaction with the people involved, including unsolicited interaction
103+
with those enforcing the Code of Conduct, is allowed during this period.
104+
Violating these terms may lead to a permanent ban.
105+
106+
### 4. Permanent Ban
107+
108+
**Community Impact**: Demonstrating a pattern of violation of community
109+
standards, including sustained inappropriate behavior, harassment of an
110+
individual, or aggression toward or disparagement of classes of individuals.
111+
112+
**Consequence**: A permanent ban from any sort of public interaction within
113+
the community.
114+
115+
## Attribution
116+
117+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118+
version 2.0, available at
119+
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
120+
121+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
122+
enforcement ladder](https://github.com/mozilla/diversity).
123+
124+
[homepage]: https://www.contributor-covenant.org
125+
126+
For answers to common questions about this code of conduct, see the FAQ at
127+
https://www.contributor-covenant.org/faq. Translations are available at
128+
https://www.contributor-covenant.org/translations.

CONTRIBUTING.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Contributing
2+
3+
Contributions are **welcome** and will be fully **credited**.
4+
5+
We accept contributions via Pull Requests on [GitHub](https://github.com/cloudinary-labs/cloudinary-laravel).
6+
7+
## Issues
8+
9+
### Creating an Issue
10+
If you find a bug, problem, or maybe the documentation just doesn't make sense, please create an Issue to document the concern.
11+
12+
### Description
13+
Please be descriptive in your Issue. The more info you provide, the more likely someone will be able to help.
14+
15+
### Code Examples
16+
If you're experiencing an issue with the code, the most helpful thing you can do is create an example where you can reproduce the problem. This can be an open source Github repo, a private repo you can share with the maintainers, a [CodeSandbox](https://codesandbox.io/), or really anything to show the issue live with code along side of it.
17+
18+
## Pull Requests
19+
20+
The project uses **[PSR-12 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-12-extended-coding-style-guide.md)**. The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer).
21+
22+
### Creating a Pull Request
23+
If you're able to fix an active Issue, feel free to create a new Pull Request addressing the problem. There are no gaurantees that the code will be merged in "as is", but chances are, if you're willing to work with the maintainers, everyone will be able to come up with a solution everyone can be happy with.
24+
25+
Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
26+
27+
If you want to do more than one thing, send multiple pull requests.
28+
29+
### Description
30+
Please be descriptive in your Pull Request. Whether big or small, it's important to be able to see the context of a change throughout the history of a project.
31+
32+
### Linking Fixed Issues
33+
If the Pull Request is addressing an Issue, please link that issue by specifying the `Fixes [Issue #]` syntax within the Pull Request.
34+
35+
### Tests
36+
Your patch won't be accepted if it doesn't have tests.
37+
38+
You can run tests with:
39+
``` bash
40+
$ composer test
41+
```
42+
43+
### Documentation
44+
Make sure the `README.md` and any other relevant documentation are kept up-to-date.
45+
46+
### Release Cycle
47+
We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
48+
49+
### Branching
50+
Create a feature branch. Don't ask us to pull from your main branch.

README.md

Lines changed: 135 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
1-
<div align="center">
2-
<h1> Cloudinary Laravel Package</h1>
3-
</div>
4-
5-
<p align="center">
6-
<a href="https://packagist.org/packages/cloudinary-labs/cloudinary-laravel">
7-
<img src="https://img.shields.io/packagist/dt/cloudinary-labs/cloudinary-laravel.svg?style=flat-square" alt="Total Downloads">
8-
</a>
9-
<a href="https://packagist.org/packages/cloudinary-labs/cloudinary-laravel">
10-
<img src="https://poser.pugx.org/cloudinary-labs/cloudinary-laravel/v/stable.svg" alt="Latest Stable Version">
11-
</a>
12-
<a href="https://packagist.org/packages/cloudinary-labs/cloudinary-laravel">
13-
<img src="https://poser.pugx.org/cloudinary-labs/cloudinary-laravel/license.svg" alt="License">
14-
</a>
15-
</p>
1+
<picture>
2+
<source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/62209650/196528621-b68e9e10-7e55-4c7d-9177-904cadbb4296.png" align="center" height=50>
3+
<source media="(prefers-color-scheme: light)" srcset="https://user-images.githubusercontent.com/62209650/196528761-a815025a-271a-4d8e-ac7e-cea833728bf9.png" align="center" height=50>
4+
<img alt="Cloudinary" src="https://user-images.githubusercontent.com/62209650/196528761-a815025a-271a-4d8e-ac7e-cea833728bf9.png" align="center" height=50>
5+
</picture>
6+
&ensp;&ensp;
7+
<picture style="padding: 50px">
8+
<source media="(prefers-color-scheme: dark)" srcset="https://user-images.githubusercontent.com/1045274/200928533-47539867-07ff-406e-aa8b-25c594652dc8.png" align="center" height=50>
9+
<source media="(prefers-color-scheme: light)" srcset="https://user-images.githubusercontent.com/1045274/200928533-47539867-07ff-406e-aa8b-25c594652dc8.png" align="center" height=50>
10+
<img alt="Laravel" src="https://user-images.githubusercontent.com/1045274/200928533-47539867-07ff-406e-aa8b-25c594652dc8.png" align="center" height=50>
11+
</picture>
12+
13+
######
14+
15+
<a href="https://packagist.org/packages/cloudinary-labs/cloudinary-laravel"><img src="https://img.shields.io/packagist/dt/cloudinary-labs/cloudinary-laravel.svg?style=flat-square" alt="Total Downloads"></a> <a href="https://packagist.org/packages/cloudinary-labs/cloudinary-laravel"><img src="https://poser.pugx.org/cloudinary-labs/cloudinary-laravel/v/stable.svg?style=flat-square" alt="Latest Stable Version"></a> <a href="https://github.com/cloudinary-devs/cloudinary-laravel/blob/main/LICENSE"><img alt="GitHub" src="https://img.shields.io/github/license/cloudinary-devs/cloudinary-laravel?label=License&style=flat-square"></a>
1616

1717
> A Laravel Package for uploading, optimizing, transforming and delivering media files with Cloudinary. Furthermore, it provides a fluent and expressive API to easily attach your media files to Eloquent models.
1818
19-
## Very Important
20-
21-
For apps using **Laravel 9**, please use the **v2.0.0** of the package which is the latest and the default. On version **8 and below**, use the **v1.x.x**.
22-
2319
## Contents
2420

2521
* [Usage](#usage)
@@ -36,6 +32,8 @@ For apps using **Laravel 9**, please use the **v2.0.0** of the package which is
3632

3733
## Usage
3834

35+
> Laravel versions **8 and below** should use the **v1.x.x**.
36+
3937
## **Upload, Retrieval & Transformation Media Method Calls**:
4038

4139
**Upload** a file (_Image_, _Video_ or any type of _File_) to **Cloudinary**, **retrieve** and **transform** via any of the following ways:
@@ -46,6 +44,8 @@ For apps using **Laravel 9**, please use the **v2.0.0** of the package which is
4644
* Using the Cloudinary Facade
4745
*/
4846

47+
use CloudinaryLabs\CloudinaryLaravel\Facades\Cloudinary;
48+
4949
// access the admin api
5050
(https://cloudinary.com/documentation/admin_api)
5151
Cloudinary::admin();
@@ -212,6 +212,90 @@ $page = Page::find(2);
212212
$page->detachMedia($file) // Example of $file is $request->file('file');
213213
```
214214

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

217301
Use the `x-cld-upload-button` Blade upload button component that ships with this Package like so:
@@ -238,6 +322,26 @@ Other Blade components you can use are:
238322
<x-cld-video public-id="awesome"></x-cld-video> // Blade Video Component for displaying videos
239323
```
240324

325+
To get the upload image link from the widget in your controller, simply set a route and controller action in your `.env`. For example:
326+
327+
```php
328+
CLOUDINARY_UPLOAD_ROUTE=api/cloudinary-js-upload
329+
CLOUDINARY_UPLOAD_ACTION=App\Http\Controllers\Api\CloudinaryController@upload
330+
```
331+
332+
Make sure to specify the full path to the controller. You should be able to get the URL like so:
333+
334+
```php
335+
...
336+
class CloudinaryController extends Controller
337+
{
338+
public function upload(Request $request)
339+
{
340+
$url = $request->get('cloud_image_url');
341+
}
342+
}
343+
```
344+
241345
## **Media Management via The Command Line**:
242346

243347
```bash
@@ -368,7 +472,17 @@ return [
368472
* Upload Preset From Cloudinary Dashboard
369473
*
370474
*/
371-
'upload_preset' => env('CLOUDINARY_UPLOAD_PRESET')
475+
'upload_preset' => env('CLOUDINARY_UPLOAD_PRESET'),
476+
477+
/**
478+
* Route to get cloud_image_url from Blade Upload Widget
479+
*/
480+
'upload_route' => env('CLOUDINARY_UPLOAD_ROUTE'),
481+
482+
/**
483+
* Controller action to get cloud_image_url from Blade Upload Widget
484+
*/
485+
'upload_action' => env('CLOUDINARY_UPLOAD_ACTION'),
372486
];
373487
```
374488

@@ -381,7 +495,7 @@ CLOUDINARY_UPLOAD_PRESET=xxxxxxxxxxxxx
381495
CLOUDINARY_NOTIFICATION_URL=
382496
```
383497

384-
***Note:** You need to get these credentials from your [Cloudinary Dashboard](https://cloudinary.com/console)*
498+
***Note:** You need to get these credentials from your [Cloudinary Dashboard](https://cloudinary.com/console). The CLOUDINARY_URL is the API Environment variable shown in your Cloudinary Dashboard. Use the Copy button there to get the full URL*
385499

386500
*If you are using a hosting service like heroku, forge, digital ocean, etc, please ensure to add the above details to your configuration variables.*
387501

0 commit comments

Comments
 (0)