{"id":23582464,"url":"https://github.com/fork/craft-embeds","last_synced_at":"2025-05-06T23:44:31.243Z","repository":{"id":66551073,"uuid":"161184739","full_name":"fork/craft-embeds","owner":"fork","description":"Allow using Embeds within Redactor. Embeds are referenced Matrix Blocks within the Redactor body.","archived":false,"fork":false,"pushed_at":"2025-03-12T14:23:05.000Z","size":310,"stargazers_count":2,"open_issues_count":3,"forks_count":1,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-03-31T04:11:15.200Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/fork.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-12-10T14:09:15.000Z","updated_at":"2025-02-27T13:02:28.000Z","dependencies_parsed_at":"2023-02-24T06:15:18.351Z","dependency_job_id":"991815ed-0f87-4a18-ada5-21624693da2f","html_url":"https://github.com/fork/craft-embeds","commit_stats":null,"previous_names":[],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fork%2Fcraft-embeds","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fork%2Fcraft-embeds/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fork%2Fcraft-embeds/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fork%2Fcraft-embeds/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fork","download_url":"https://codeload.github.com/fork/craft-embeds/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252788404,"owners_count":21804280,"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":[],"created_at":"2024-12-27T01:11:40.435Z","updated_at":"2025-05-06T23:44:31.237Z","avatar_url":"https://github.com/fork.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://www.fork.de\"\u003e\n    \u003cimg src=\"./assets/fork-logo.png\" width=\"156\" height=\"30\" alt=\"Fork Logo\" /\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n# Embeds plugin for Craft CMS 5.x\n\nNOTE: This Plugin is not meant for actual use with Craft 5. The current release includes a script for migrating\nembeds to CKEditor with inline blocks.\n\n## Requirements\n\nThis plugin requires Craft CMS 5 or later and the Craft Redactor and CKEditor plugins.\nThe plugin is not actually working with current Craft CMS 5.0.\n\n## Migrating to CKEditor\n\nIn order to migrate your embeds fields to CKEditor fields with inline blocks, do the following steps:\n\n1. Install the CKEditor plugin, if not done already\n2. Migrate all your Redactor fields to CKEditor fields and ignore the warnings about missing config settings for the\nembeds plugin\n3. Check your htmlpurifier config. Remove `\"AutoFormat.RemoveEmpty\": true,`, if given. This setting causes the purifier\nto remove Entry blocks from inside the CKEditor content.\n4. Run `php craft gc/run`! The migration script might encounter errors if you don't.\n5. In your local environment, run `php craft embeds/migrate-ckeditor [--copy-field=embedsCopy] [--embeds-field=embeds]`.\nThis might take a while because the script handles every entry, draft and revision with these fields. Run this script\nfor every combination of Embeds and Embeds Copy field that you have and note every one of those.\n6. Adjust your rendering code to the new CKEditor field (See below).\n7. Commit and deploy the changes made to the project config. (It should at least add the `createEntry` Button to the\nCKEditor config)\n8. Run the scripts from steps no. 4 and 5 in every other environment after deploying.\n9. You should now have CKEditor fields with your old embeds as inline blocks in the correct position inside the content.\n10. After everything is deployed, you can remove the old Embeds Matrix field and the Embeds plugin.\n\n### Rendering with CKEditor\n\nThe `mergeEmbeds()` function won't work anymore. And you'll eventually remove this plugin completely. So\nrendering is up to you now. The following code example might help you as a starter:\n\n```php\n        # $field is your CKEditor field\n        $chunks = [];\n        foreach ($field-\u003egetChunks() as $chunk) {\n            if ($chunk instanceof craft\\ckeditor\\data\\Markup) {\n                $chunks[] = [\n                    'type' =\u003e \"copy\",\n                    'html' =\u003e $chunk-\u003egetHtml(),\n                ];\n            } else {\n                /** @var craft\\ckeditor\\data\\Entry $chunk */\n                $embed = $chunk-\u003egetEntry();\n                $type = rtrim($embed-\u003etype-\u003ehandle);\n                $embedData = $this-\u003ehandleEmbed($embed); // This is where you handle your embeds\n                $chunks[] = [\n                    'type' =\u003e $type,\n                    'data' =\u003e $embedData,\n                ];\n            }\n        }\n\n        return $chunks;\n```\n\nAnother approach would be to switch to using\n[Partials](https://craftcms.com/docs/5.x/system/elements.html#element-partials) for rendering.\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg src=\"./assets/heart.png\" width=\"38\" height=\"41\" alt=\"Fork Logo\" /\u003e\n\n  \u003cp\u003eBrought to you by \u003ca href=\"https://www.fork.de\"\u003eFork Unstable Media GmbH\u003c/a\u003e\u003c/p\u003e\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffork%2Fcraft-embeds","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffork%2Fcraft-embeds","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffork%2Fcraft-embeds/lists"}