Skip to content

Commit

Permalink
feat: add iframe max-width max-height options
Browse files Browse the repository at this point in the history
  • Loading branch information
sachinchoolur committed Oct 28, 2021
1 parent c173d32 commit cbaf4f1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/lg-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -385,10 +385,20 @@ export interface LightGalleryCoreSettings {
iframeWidth: string;

/**
* Set width for iframe.
* Set height for iframe.
*/
iframeHeight: string;

/**
* Set max width for iframe.
*/
iframeMaxWidth: string;

/**
* Set max height for iframe.
*/
iframeMaxHeight: string;

/**
* Enable download button.
* @description By default download url will be taken from data-src/href attribute but it supports only for modern browsers.
Expand Down Expand Up @@ -543,6 +553,8 @@ export const lightGalleryCoreSettings: LightGalleryCoreSettings = {
index: 0,
iframeWidth: '100%',
iframeHeight: '100%',
iframeMaxWidth: '100%',
iframeMaxHeight: '100%',
download: true,
counter: true,
appendCounterTo: '.lg-toolbar',
Expand Down
4 changes: 3 additions & 1 deletion src/lg-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,13 @@ const utils = {
getIframeMarkup(
iframeWidth: string,
iframeHeight: string,
iframeMaxWidth: string,
iframeMaxHeight: string,
src?: string,
iframeTitle?: string,
): string {
const title = iframeTitle ? 'title="' + iframeTitle + '"' : '';
return `<div class="lg-video-cont lg-has-iframe" style="width:${iframeWidth}; height: ${iframeHeight}">
return `<div class="lg-video-cont lg-has-iframe" style="width:${iframeWidth}; max-width:${iframeMaxWidth}; height: ${iframeHeight}; max-height:${iframeMaxHeight}">
<iframe class="lg-object" frameborder="0" ${title} src="${src}" allowfullscreen="true"></iframe>
</div>`;
},
Expand Down
2 changes: 2 additions & 0 deletions src/lightgallery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1120,6 +1120,8 @@ export class LightGallery {
const markup = utils.getIframeMarkup(
this.settings.iframeWidth,
this.settings.iframeHeight,
this.settings.iframeMaxWidth,
this.settings.iframeMaxHeight,
src,
currentGalleryItem.iframeTitle,
);
Expand Down

0 comments on commit cbaf4f1

Please sign in to comment.