October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
Cloudinary

How to Generate an Image URL for a Website

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To generate an image URL for a website, first put the image file somewhere your site’s visitors can access—such as your site’s deployed assets, object storage, or an image-delivery service. Then use that location as the image’s URL in an HTML <img src="..."> element. A URL points to the file; it does not create, upload, or host the image.

What an image URL is—and what it is not

An image URL is the address at which a browser can request an image file. For example, images/dinosaur.jpg is a relative path that can refer to an image deployed with a site, while https://www.example.com/images/dinosaur.jpg is an absolute URL naming a host and path.

There is no general HTML command that creates a hosted image URL from a picture on your computer. You must first upload or deploy the file to a location that can serve it. Once that is done, use the file’s path or delivery URL in your page. If the file is private or the server does not allow visitors to read it, the URL will not make it accessible.

Use an image URL in HTML

Put the address in the src attribute and give the image meaningful alternative text in alt:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option
<img src="images/dinosaur.jpg" alt="Dinosaur">

The browser requests the resource specified by src. The alt text is a textual replacement for the image, useful to people using screen readers and when the image cannot be displayed. Describe the image’s relevant content rather than repeating its filename.

For an image hosted on a separately named domain, use its complete address instead:

<img src="https://www.example.com/images/dinosaur.jpg" alt="Dinosaur">

HTML also supports srcset for offering alternative image sources; an image element must have at least src or srcset. If you know the image’s intrinsic dimensions, providing width and height can reserve its layout space while it loads:

<img src="images/dinosaur.jpg" alt="Dinosaur" width="640" height="480">

Choose where to host the image

The right route depends on who should control the file, how you plan to update it, and what delivery features you need. Neither self-hosting nor a managed image service is universally better for cost or performance; those outcomes depend on the configuration and service.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Option How the URL is formed What to consider
Deploy the image with your website Use a relative path such as images/dinosaur.jpg, or the site’s absolute host-and-path URL. You control the asset and path through your site deployment. Keep file and directory capitalization consistent with the deployed names.
Object storage or a website endpoint Use the endpoint and object path provided by the storage configuration. Set permissions so intended viewers can read the object. AWS S3 website endpoints are HTTP-only; AWS documents CloudFront or Amplify Hosting for HTTPS delivery.
Managed image service Use the delivery URL associated with the uploaded asset; some services also accept transformation parameters. The service manages delivery URL conventions and may provide on-demand transformations. Those URL formats and capabilities are service-specific.

Use images that you own or have permission to embed. Pointing your page at another website’s image without permission can also leave you dependent on a file and URL controlled by someone else.

Method 1: deploy the image with your site

  1. Add the file to the site’s assets. For example, place dinosaur.jpg beside the HTML file, or put it in an images subdirectory.
  2. Write the path relative to the page. If the page and file share a directory, use dinosaur.jpg. If the file is inside images, use images/dinosaur.jpg.
  3. Reference the file in the page. Set src to that path and include appropriate alt text.
  4. Deploy both the page and image. The URL only works for visitors if the image is actually present at the deployed location.
  5. Check the published page. Test from the page’s real deployed address, not only from a local preview. Confirm that the image request succeeds and that capitalization matches the deployed file and directory names.

A relative URL is resolved in relation to the page’s location. If a page lives in a different directory than you expected, the same relative path can point somewhere else. Use the browser’s actual page location when diagnosing a path that works on one page but not another.

Method 2: use an object-storage URL

You can store an image as an object and reference the URL formed from the storage website endpoint and object path. The intended audience must have permission to read it. A URL to an object that is not publicly readable will not make that object public by itself.

For Amazon S3 static website hosting, the website endpoint is part of the URL. AWS states that these website endpoints do not support HTTPS. If the image needs HTTPS delivery, AWS documents CloudFront or Amplify Hosting as alternatives for serving the site. Check the endpoint and access configuration you use rather than assuming that every S3 URL has the same behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Keep the object name and path aligned with the URL. AWS notes that the index document name in S3 website configuration is case-sensitive; more generally, a difference in capitalization between a deployed name and the requested path can prevent the expected resource from being found.

Method 3: generate a delivery URL with an image service

A managed image service can provide a URL for an uploaded asset and, depending on the service, encode transformations such as resizing or format changes into the delivery URL. This is not a built-in feature of HTML: the service defines how its asset identifiers and transformation parameters work.

Cloudinary URL pattern

Cloudinary documents a basic image delivery URL in this form:

https://res.cloudinary.com/<cloud_name>/image/upload/<public_id>.<extension>

Replace the placeholders with the cloud name and public ID for the asset in your account, plus its extension where applicable. The resulting delivery URL can be used as an image element’s src. Cloudinary also documents transformations in delivery URLs, but their syntax is specific to Cloudinary.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Generate one with Cloudinary’s JavaScript library

Cloudinary’s documented JavaScript example configures a cloud name, selects an image by public ID, and calls toURL():

import { Cloudinary } from "@cloudinary/url-gen";

const cloudinary = new Cloudinary({
  cloud: { cloudName: "demo" }
});

const imageUrl = cloudinary.image("sample").toURL();
console.log(imageUrl);

In that example, the generated URL is https://res.cloudinary.com/demo/image/upload/sample. Use the account’s cloud name and the identifier for your own uploaded asset when generating a URL for your site.

Keep upload credentials on the server

Generating a delivery URL from an asset identifier is different from uploading an image. For uploads, Cloudinary documents API authentication options and warns against exposing the API secret in public client-side code. Keep secrets on a trusted server, or use the service’s supported client-upload flow where appropriate. A secret embedded in browser JavaScript can be read by visitors and should not be treated as private.

Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

Make sure the URL will keep working

Before publishing an image URL, check the practical details that determine whether it works for the intended audience:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Deployment location: A relative path is resolved from the page’s location. Confirm it points to the intended directory after deployment.
  • Exact spelling and case: Match the deployed filename and directory names exactly.
  • Viewer access: Confirm the image host permits the people or systems expected to load the page to read the file.
  • Transport security: If the page is served over HTTPS, choose an image delivery URL that supports HTTPS; an HTTP-only endpoint is not equivalent.
  • URL stability: A self-hosted path can stop working if a file is renamed or moved. A managed service’s URL depends on its asset identifier and service-specific rules. Plan for references to change when replacing or reorganizing assets.
  • Embedding permission: Use files you control or have permission to embed rather than relying on another site’s image address.

For a page that loads an image from a different host, test the image on the deployed page as well as opening its address directly. The page’s real location, the file’s access settings, and the exact URL all matter.

Or skip the browser setup

If your goal is to capture a webpage as an image rather than host an image file for use in an <img> element, ScreenshotNeo is a website screenshot API and MCP server. It captures a webpage; its screenshot URL or response is not a substitute for uploading an image to your site or image host. The following GET request saves a screenshot response to a local file. See the ScreenshotNeo API documentation for request details.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before the shot; each cleanup step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and responses report the page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents using Claude, Cursor, or another MCP client. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Sign up for 1,000 free screenshots a month, with no card required.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot an image that does not appear

The browser reports that the image cannot be found

Check whether the file was included in the deployment, whether the relative URL is being resolved from the page’s actual directory, and whether every directory and filename matches the deployed path exactly.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The URL opens for you but not for visitors

Check the object or host’s read permissions and confirm that the URL is intended to be available to those visitors. A URL is only an address; it does not grant access to a protected file.

The address works over HTTP but not HTTPS

Check whether the selected endpoint supports HTTPS. In particular, AWS S3 website endpoints are HTTP-only; AWS documents CloudFront or Amplify Hosting for HTTPS delivery.

The image service URL does not match your asset

Verify the account’s cloud name, asset public ID, extension, and the service’s documented URL format. Transformation syntax is vendor-specific, so do not assume a URL pattern from one image service will work on another.

The upload works only when a secret is in the browser

Do not publish an API secret in client-side code. Move authenticated upload work to a trusted server or use the provider’s supported client-upload flow. A publicly visible delivery URL and a private upload credential serve different purposes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Which approach should you use?

  • Choose site assets when you deploy and maintain the website’s files together and a stable relative path suits your setup.
  • Choose object storage when you want the file hosted separately, after checking access permissions and HTTPS delivery for the endpoint.
  • Choose a managed image service when its asset delivery and transformation features fit your needs and you are comfortable using its URL conventions.

Whichever route you choose, the core HTML stays simple: make the image available at a reachable address, put that address in src, and write useful alt text.

Quick Recap

SaleBestseller No. 1
HTML and CSS: Design and Build Websites
HTML and CSS: Design and Build Websites
HTML CSS Design and Build Web Sites; Comes with secure packaging; It can be a gift option
$14.18
SaleBestseller No. 3
SaleBestseller No. 4
Web Design with HTML, CSS, JavaScript and jQuery Set
Web Design with HTML, CSS, JavaScript and jQuery Set
Brand: Wiley; Set of 2 Volumes
$35.05

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Read next

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.