📜  unsplash url (1)

📅  最后修改于: 2023-12-03 15:20:54.459000             🧑  作者: Mango

Unsplash URL

Unsplash is a website that provides free, high-quality photos that can be used for any purpose. Each photo is uploaded by a professional photographer and can be downloaded in a variety of sizes.

Using Unsplash URLs in Your Code

One of the features of Unsplash is the ability to generate URLs for each photo. These URLs can be used to display the photo on your website or in your application.

To use an Unsplash URL in your code, simply copy the URL for the desired photo and paste it into your HTML or CSS code. For example, to display a photo in an <img> tag in HTML, you would use the following code:

<img src="https://unsplash.com/photos/example" alt="Example photo from Unsplash">

In CSS, you could use the following code to set a background image:

.background {
  background-image: url(https://unsplash.com/photos/example);
}
Customizing Unsplash URLs

Unsplash URLs can also be customized to include specific parameters, such as the image size and quality, or to specify a specific photographer or collection.

For example, to specify a specific image size, you can add a parameter to the URL like so:

<img src="https://unsplash.com/photos/example?w=800" alt="Example photo from Unsplash">

This would display the photo with a width of 800 pixels.

Other available parameters include h (height), fit (how the image should fit into the available space), and q (image quality).

To specify a specific photographer or collection, you can use the following URL format:

<img src="https://unsplash.com/photos/<PHOTO-ID>?utm_source=your_app_name&utm_medium=referral&utm_campaign=api-credit" alt="Example photo from photographer on Unsplash">

Replacing <PHOTO-ID> with the actual ID of the photo you want to use and filling in the utm_ parameters as appropriate.

Conclusion

Overall, Unsplash URLs provide a quick and easy way to add high-quality photos to your website or application. With the ability to customize the URL with specific parameters, you can tailor the images to fit your needs.