Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make embedUrl an optional callback #58

Merged
merged 2 commits into from
Sep 6, 2024

Conversation

espertype
Copy link
Contributor

@espertype espertype commented Aug 2, 2024

This is a small tweak meant to allow constructing the embedUrl programmatically.

Here is an example of how it could be used in combination with CookieConsent, based on the StackBlitz example.
Depending on the user consent for the 'vimeo_analytics' service, the Do Not Track URL parameter for Vimeo is appended to the URL:

const im = iframemanager();

im.run({
    onChange: ({changedServices, eventSource}) => {
        if (eventSource.type === 'click') {
            // ...
        }
    },

    currLang: 'en',

    services: {
        vimeo: {
            // embedUrl: 'https://player.vimeo.com/video/{data-id}',
            embedUrl: () => {
                return CookieConsent.acceptedService('vimeo_analytics', 'analytics') ?
                    'https://player.vimeo.com/video/{data-id}'
                    : 'https://player.vimeo.com/video/{data-id}?dnt=1';
            },
            iframe: {
                allow: 'fullscreen; picture-in-picture;',
            },

            thumbnailUrl: 'https://example.com/img/vimeo-placeholder.jpg',

            languages: {
                en: {
                    notice:
                        'This content is hosted by a third party. By showing the external content you accept the <a rel="noreferrer noopener" href="https://vimeo.com/terms" target="_blank">terms and conditions</a> of vimeo.com.',
                    loadBtn: 'Load once',
                    loadAllBtn: "Don't ask again",
                },
            },
        },
    },
});

Copy link

stale bot commented Sep 1, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Sep 1, 2024
@orestbida orestbida merged commit 19c2baa into orestbida:main Sep 6, 2024
@orestbida
Copy link
Owner

Thanks for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants