You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/includes/_methods.md
+53-9Lines changed: 53 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -167,9 +167,29 @@ Field Name | Purpose | Field Format
167
167
(asyncAPILoader=> {
168
168
constAPI=awaitAPILoader.create();
169
169
170
+
// Callback function to be called when your HTML slide is rendered.
171
+
constmyCallback= (data) => {
172
+
// The `el` property is the top level HTML element where your content will be placed. You may modify this element or insert additional elements into it.
173
+
const { el } = data;
174
+
175
+
// The height and width variables give you size information about the content placement location.
176
+
const { width, height } = data;
177
+
178
+
el.style.height= height;
179
+
el.style.width= width;
180
+
181
+
// The full Vehicle Object is available in the callback data.
182
+
const { vehicle } = data;
183
+
184
+
// This destructures a few variables out of that vehicle object for later use.
185
+
// The height and width variables give you size information about the content placement location.
src:'https://via.placeholder.com/530x360.png?text=Secondary HTML Content Placeholder'
223
243
},
224
244
{
225
245
type:'image',
@@ -237,9 +257,9 @@ Field Name | Purpose | Field Format
237
257
})(window.DDC.APILoader);
238
258
```
239
259
240
-
The `insertGalleryContent` method allows you to add media to media galleries across various pages of Dealer.com sites. The only currently supported target is `vehicle-media`, which will insert media into the media carousels on Search Results Pages and Vehicle Details Pages.
260
+
The `insertGalleryContent` method allows you to add media to galleries across various pages of Dealer.com sites. The only currently supported target is `vehicle-media`, which will insert media into the media carousels on Search Results Pages (Images only) and Vehicle Details Pages (Images and HTML slides).
241
261
242
-
`arrayOfObjects` is an array of objects describing the media to be inserted. Each object requires a `vin` field for the target vehicle, an `images` array with fields describing the images to insert for that vehicle as well as an optional `insertMethod`. The `type` field specifies the type of media to be inserted. The only currently supported media type is `image`. Utilizing `vehicle-data-updated-v1` to know when the list of vehicles changes combined with `API.utils.getAttributeForVehicles`, you can easily obtain a list of the VINs for vehicles shown on the page. With this data, you could query your service to get the dataset of imagery for those vehicles, then construct the array of objects for `API.insertGalleryContent`. See the example code for more details on this approach.
262
+
`arrayOfObjects` is an array of objects describing the media to be inserted. Each object requires a `vin` field for the target vehicle, an `images` array with fields describing the images and other HTML content to insert for that vehicle as well as an optional `insertMethod`. The `type` field specifies the type of media to be inserted. The available options are `image` and `html`. Utilizing `vehicle-data-updated-v1` to know when the list of vehicles changes combined with `API.utils.getAttributeForVehicles`, you can easily obtain a list of the VINs for vehicles shown on the page. With this data, you could query your service to get the dataset of imagery and other content for those vehicles, then construct the array of objects for `API.insertGalleryContent`. See the example code for more details on this approach.
243
263
244
264
The `insertMethod` accepts the following string values:
245
265
@@ -252,9 +272,33 @@ The `images` array objects support the following additional attributes:
252
272
253
273
Name | Description
254
274
-------------- | --------------
275
+
`type` | Expected values are `image` or `html`. The `html` and `callback` attributes are only used when type is set to `html`.
276
+
`src` | HTTPS url to the image to be inserted.
255
277
`position` | Where to insert the image. `primary` is used for content that should be displayed to the user as soon as it loads -- as long as the user has not explicitly performed an action to look at pre-existing media. `secondary` is used for content that should be displayed soon, but not replace the pre-existing main image. `last` is used to append content to the end of an existing gallery.
256
278
`src` | HTTPS url to the image to be inserted.
257
279
`thumbnail` | HTTPS url to a thumbnail of the image to be inserted. For performance, it is ideal to provide a low resolution thumbnail that can be used for a preview of the inserted image, however, `src` will be used if `thumbnail` is not provided.
280
+
`html` | HTML markup to render when the user clicks on the placeholder image. This field is optional, as you can also use the `callback` function to create your markup.
281
+
`callback` | A callback function to call when the user clicks on the placeholder image. This allows you to construct the HTML to display dynamically, with relevant data in context.
282
+
283
+
The `callback` function you specify is called with a single parameter, which is an object with the following structure:
284
+
285
+
/**
286
+
* Initial HTML Element where your markup can be inserted. You can modify this element or insert other content inside of it.
287
+
* @type {HTMLElement} el
288
+
289
+
* A unique ID for the location where your content will be inserted (either 'carousel' or 'photoswipe'). There are two insert locations on the Vehicle Details page. If your code requires a unique location on the page by ID (some video players may require this), you can add the `locationId` value to your target ID to make them unique.
290
+
* @type {string} locationId
291
+
292
+
* The available width for your target location. This can be useful when constructing iframes to insert, etc.
293
+
* @type {number} width
294
+
295
+
* The available height for your target location. This can be useful when constructing iframes to insert, etc.
296
+
* @type {number} height
297
+
298
+
* The Vehicle Object for the current vehicle, so you can use vehicle data when constructing your markup.
0 commit comments