MCPcopy
hub / github.com/faker-js/faker / url

Method url

src/modules/image/index.ts:119–147  ·  view source on GitHub ↗

* Generates a random image url. * * @remark This method generates a random string representing an URL from an external provider. Faker is not responsible for the content of the image or the service providing it. * * @param options Options for generating a URL for an image. * @param op

(
    options: {
      /**
       * The width of the image.
       *
       * @default faker.number.int({ min: 1, max: 3999 })
       */
      width?: number;
      /**
       * The height of the image.
       *
       * @default faker.number.int({ min: 1, max: 3999 })
       */
      height?: number;
    } = {}
  )

Source from the content-addressed store, hash-verified

117 * @since 8.0.0
118 */
119 url(
120 options: {
121 /**
122 * The width of the image.
123 *
124 * @default faker.number.int({ min: 1, max: 3999 })
125 */
126 width?: number;
127 /**
128 * The height of the image.
129 *
130 * @default faker.number.int({ min: 1, max: 3999 })
131 */
132 height?: number;
133 } = {}
134 ): string {
135 const {
136 width = this.faker.number.int({ min: 1, max: 3999 }),
137 height = this.faker.number.int({ min: 1, max: 3999 }),
138 } = options;
139
140 const urlMethod = this.faker.helpers.arrayElement([
141 ({ width, height }: { width?: number; height?: number }) =>
142 this.urlPicsumPhotos({ width, height, grayscale: false, blur: 0 }),
143 // Other providers may be added back here in future versions.
144 ]);
145
146 return urlMethod({ width, height });
147 }
148
149 /**
150 * Generates a random image url provided via https://loremflickr.com.

Callers 5

image.spec.tsFile · 0.45
image.spec.tsFile · 0.45
internet.spec.tsFile · 0.45
api.cy.tsFile · 0.45
guide.cy.tsFile · 0.45

Calls 3

urlPicsumPhotosMethod · 0.95
intMethod · 0.80
arrayElementMethod · 0.80

Tested by

no test coverage detected