{"id":15383121,"url":"https://github.com/trovster/commonmark-ext-youtube-iframe","last_synced_at":"2026-04-19T04:32:51.958Z","repository":{"id":57679189,"uuid":"481275315","full_name":"trovster/commonmark-ext-youtube-iframe","owner":"trovster","description":"Extension for league/commonmark to replace YouTube link with an iframe.","archived":false,"fork":false,"pushed_at":"2022-12-06T14:02:21.000Z","size":19,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-03-07T12:47:07.043Z","etag":null,"topics":["commonmark","extension","iframe","markdown","php","youtube"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trovster.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-13T15:39:02.000Z","updated_at":"2024-01-04T10:09:27.000Z","dependencies_parsed_at":"2023-01-23T18:45:11.129Z","dependency_job_id":null,"html_url":"https://github.com/trovster/commonmark-ext-youtube-iframe","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trovster%2Fcommonmark-ext-youtube-iframe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trovster%2Fcommonmark-ext-youtube-iframe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trovster%2Fcommonmark-ext-youtube-iframe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trovster%2Fcommonmark-ext-youtube-iframe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trovster","download_url":"https://codeload.github.com/trovster/commonmark-ext-youtube-iframe/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245937896,"owners_count":20696985,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["commonmark","extension","iframe","markdown","php","youtube"],"created_at":"2024-10-01T14:35:23.548Z","updated_at":"2026-04-19T04:32:46.920Z","avatar_url":"https://github.com/trovster.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# YouTube iframe extension\n\nAn extension for [league/commonmark](https://github.com/thephpleague/commonmark)\nversion 2 built using PHP 8.0. This replaces YouTube links with the embed iframe.\n\nThe extension supports for the primary YouTube URL, with and without prefixed with\nthe `www`. It also supports the short shareable URL using the `youtu.be` domain.\n\nInitially based on the [YouTube extension](https://github.com/zoonru/commonmark-ext-youtube-iframe).\n\n## Installation\n\nThe project should be installed via Composer:\n\n```bash\ncomposer require surface/commonmark-ext-youtube-iframe\n```\n\n## Usage\n\nConfigure your CommonMark `Environment` and add the extension.\n\n```php\nuse League\\CommonMark\\Environment\\Environment;\nuse League\\CommonMark\\MarkdownConverter as Converter;\nuse Surface\\CommonMark\\Ext\\YouTubeIframe\\Extension as YouTubeExtension;\n\n$options = [\n    'youtube_iframe' =\u003e [\n        'width' =\u003e 800,\n        'height' =\u003e 600,\n    ]\n];\n\n$environment = new Environment($options);\n$environment-\u003eaddExtension(new YouTubeExtension());\n\n$converter = new Converter($environment);\n\necho $converter-\u003econvert('[](https://youtu.be/xxx)');\necho $converter-\u003econvert('[](https://www.youtube.com/watch?v=xxx)');\necho $converter-\u003econvert('[](https://youtu.be/xxx?height=480)');\necho $converter-\u003econvert('[](https://www.youtube.com/watch?v=xxx\u0026width=640)');\n```\n\n### Dimensions\n\nYou can control the dimensions of the videos by using the `width` and\n`height` configuration options.\n\nYou can also configure the dimensions using query parameters on the embed URL.\nYou can provide the `height` or `width` or *both*.\n\n```html\n?width=640\n?height=480\n?width=640\u0026height=480\n```\n\n### Full URL\n\nYou can disable the parsing of full YouTube URLs (with or without the www) by\nusing the following option. If this option is disabled, only URLs under the\n‘short’ domain will be used (`youtu.be`).\n\n```php\n$options = [\n    'youtube_iframe' =\u003e [\n        'full_url' =\u003e false,\n    ]\n];\n```\n\n## Testing\n\nThere are Unit and Integration tests for the project. These can be run using\nthe following commands:\n\n```bash\ncomposer test\ncomposer run test\ncomposer run test-unit\ncomposer run test-integration\n```\n\nThere are also scripts to run code sniffer, mess detector and static analysis:\n\n```bash\ncomposer run sniff\ncomposer run mess\ncomposer run stan\n```\n\n## Changelog\n\nPlease refer to the [CHANGELOG](CHANGELOG.md) for more information on what has\nchanged recently.\n\n## License\n\nThis library is licensed under the MIT license. See the\n[License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrovster%2Fcommonmark-ext-youtube-iframe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrovster%2Fcommonmark-ext-youtube-iframe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrovster%2Fcommonmark-ext-youtube-iframe/lists"}