src/js/glightbox.js
function getSlideData(element = null, settings) {
    let data = {
        href: '',
        title: '',
        type: '',
        description: '',
        descPosition: 'bottom',
        effect: '',
        node: element
    };

    if (utils.isObject(element) && !utils.isNode(element)){
        return extend(data, element);
    }

    let url = '';
    let config = element.getAttribute('data-glightbox')
    let nodeType = element.nodeName.toLowerCase();
    if (nodeType === 'a')
        url = element.href;
    if (nodeType === 'img')
        url = element.src;

    data.href = url;

    each(data, (val, key) => {
        if (utils.has(settings, key)) {
            data[key] = settings[key];
        }
        const nodeData = element.dataset[key];
        if (!utils.isNil(nodeData)) {
            data[key] = nodeData;
        }
    });

    if (!data.type) {
        data.type = getSourceType(url);
    }

    if (!utils.isNil(config)) {
        let cleanKeys = [];
        each(data, (v, k) => {
            cleanKeys.push(';\\s?' + k);
        })
        cleanKeys = cleanKeys.join('\\s?:|');
        if (config.trim() !== '') {
            each(data, (val, key) => {
                const str = config;
                const match = '\s?' + key + '\s?:\s?(.*?)(' + cleanKeys + '\s?:|$)';
                const regex = new RegExp(match);
                const matches = str.match(regex);

                if (matches && matches.length && matches[1]) {
                    const value = matches[1].trim().replace(/;\s*$/, '');
                    data[key] = value;
                }
            });
        }
    } else {
        if (nodeType == 'a') {
            let title = element.title
            if (!utils.isNil(title) && title !== '') data.title = title;
        }
        if (nodeType == 'img') {
            let alt = element.alt
            if (!utils.isNil(alt) && alt !== '') data.title = alt;
        }
        let desc = element.getAttribute('data-description')
        if (!utils.isNil(desc) && desc !== '') data.description = desc;
    }
    let nodeDesc = element.querySelector('.glightbox-desc')
    if (nodeDesc) {
        data.description = nodeDesc.innerHTML;
    }

    const defaultWith = (data.type == 'video' ? settings.videosWidth : settings.width);
    const defaultHeight = (data.type == 'video' ? settings.videosHeight : settings.height);

    data.width = (utils.has(data, 'width') ? data.width : defaultWith);
    data.height = (utils.has(data, 'height') ? data.height : defaultHeight);

    return data;
}
function getSlideData(element = null, settings) {
    let data = {
        href: '',
        title: '',
        type: '',
        description: '',
        descPosition: 'bottom',
        effect: '',
        node: element
    };

    if (utils.isObject(element) && !utils.isNode(element)){
        return extend(data, element);
    }

    let url = '';
    let config = element.getAttribute('data-glightbox')
    let nodeType = element.nodeName.toLowerCase();
    if (nodeType === 'a')
        url = element.href;
    if (nodeType === 'img')
        url = element.src;

    data.href = url;

    each(data, (val, key) => {
        if (utils.has(settings, key)) {
            data[key] = settings[key];
        }
        const nodeData = element.dataset[key];
        if (!utils.isNil(nodeData)) {
            data[key] = nodeData;
        }
    });

    if (!data.type) {
        data.type = getSourceType(url);
    }

    if (!utils.isNil(config)) {
        let cleanKeys = [];
        each(data, (v, k) => {
            cleanKeys.push(';\\s?' + k);
        })
        cleanKeys = cleanKeys.join('\\s?:|');
        if (config.trim() !== '') {
            each(data, (val, key) => {
                const str = config;
                const match = '\s?' + key + '\s?:\s?(.*?)(' + cleanKeys + '\s?:|$)';
                const regex = new RegExp(match);
                const matches = str.match(regex);

                if (matches && matches.length && matches[1]) {
                    const value = matches[1].trim().replace(/;\s*$/, '');
                    data[key] = value;
                }
            });
        }
    } else {
        if (nodeType == 'a') {
            let title = element.title
            if (!utils.isNil(title) && title !== '') data.title = title;
        }
        if (nodeType == 'img') {
            let alt = element.alt
            if (!utils.isNil(alt) && alt !== '') data.title = alt;
        }
        let desc = element.getAttribute('data-description')
        if (!utils.isNil(desc) && desc !== '') data.description = desc;
    }
    let nodeDesc = element.querySelector('.glightbox-desc')
    if (nodeDesc) {
        data.description = nodeDesc.innerHTML;
    }

    const defaultWith = (data.type == 'video' ? settings.videosWidth : settings.width);
    const defaultHeight = (data.type == 'video' ? settings.videosHeight : settings.height);

    data.width = (utils.has(data, 'width') ? data.width : defaultWith);
    data.height = (utils.has(data, 'height') ? data.height : defaultHeight);

    return data;
}
function getSlideData ( element = null , settings ) { let data = { href : '' , title : '' , type : '' , description : '' , descPosition : 'bottom' , effect : '' , node : element } ; if ( utils . isObject ( element ) && ! utils . isNode ( element ) ) { return extend ( data , element ) ; } let url = '' ; let config = element . getAttribute ( 'data-glightbox' ) let nodeType = element . nodeName . toLowerCase ( ) ; if ( nodeType === 'a' ) url = element . href ; if ( nodeType === 'img' ) url = element . src ; data . href = url ; each ( data , ( val , key ) => { if ( utils . has ( settings , key ) ) { data [ key ] = settings [ key ] ; } const nodeData = element . dataset [ key ] ; if ( ! utils . isNil ( nodeData ) ) { data [ key ] = nodeData ; } } ) ; if ( ! data . type ) { data . type = getSourceType ( url ) ; } if ( ! utils . isNil ( config ) ) { let cleanKeys = [ ] ; each ( data , ( v , k ) => { cleanKeys . push ( ';\\s?' + k ) ; } ) cleanKeys = cleanKeys . join ( '\\s?:|' ) ; if ( config . trim ( ) !== '' ) { each ( data , ( val , key ) => { const str = config ; const match = '\s?' + key + '\s?:\s?(.*?)(' + cleanKeys + '\s?:|$)' ; const regex = new RegExp ( match ) ; const matches = str . match ( regex ) ; if ( matches && matches . length && matches [ 1 ] ) { const value = matches [ 1 ] . trim ( ) . replace ( / ;\s*$ / , '' ) ; data [ key ] = value ; } } ) ; } } else { if ( nodeType == 'a' ) { let title = element . title if ( ! utils . isNil ( title ) && title !== '' ) data . title = title ; } if ( nodeType == 'img' ) { let alt = element . alt if ( ! utils . isNil ( alt ) && alt !== '' ) data . title = alt ; } let desc = element . getAttribute ( 'data-description' ) if ( ! utils . isNil ( desc ) && desc !== '' ) data . description = desc ; } let nodeDesc = element . querySelector ( '.glightbox-desc' ) if ( nodeDesc ) { data . description = nodeDesc . innerHTML ; } const defaultWith = ( data . type == 'video' ? settings . videosWidth : settings . width ) ; const defaultHeight = ( data . type == 'video' ? settings . videosHeight : settings . height ) ; data . width = ( utils . has ( data , 'width' ) ? data . width : defaultWith ) ; data . height = ( utils . has ( data , 'height' ) ? data . height : defaultHeight ) ; return data ; }
Get slide data

@param {node} element
Get slide data