Skip to content

Instantly share code, notes, and snippets.

Avatar

Adam Zimmermann adamzimmermann

View GitHub Profile
@adamzimmermann
adamzimmermann / FilterImageToken.php
Created May 18, 2021
Converts custom media tokens into responsive images.
View FilterImageToken.php
<?php
namespace Drupal\chromatic_image\Plugin\Filter;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Render\RendererInterface;
use Drupal\filter\FilterProcessResult;
use Drupal\filter\Plugin\FilterBase;
@adamzimmermann
adamzimmermann / migrate.sh
Last active Jan 6, 2022
Migration Script with Limit/Looping
View migrate.sh
#!/bin/bash
migrate_loop()
{
# Better readability with separation.
echo "========================";
# Get the output of the drush status.
drush_output=$(drush ms "$1" --format string);
# Split output string into an array.
@adamzimmermann
adamzimmermann / ExampleMigrateSourceImage.php
Created Aug 15, 2016
Drupal Migrate class for using images as a migration source.
View ExampleMigrateSourceImage.php
<?php
/**
* Source Migration class for finding image tags in markup.
*/
class ExampleMigrateSourceImage extends MigrateSource {
/**
* The string of HTML content.
*/
@adamzimmermann
adamzimmermann / ExampleImageMigration.php
Last active Aug 15, 2016
Drupal Migrate class for creating image entities.
View ExampleImageMigration.php
<?php
/**
* Migrate images into entities.
*/
class ExampleImageMigration extends Migration {
/**
* {@inheritdoc}
*/
@adamzimmermann
adamzimmermann / example_wordpress_migrate.drush.inc
Created Aug 24, 2015
Programatically Creating and Storing WordPress Migrate Migrations in Drupal
View example_wordpress_migrate.drush.inc
/**
* Define the WordPress blogs to be imported.
*/
function example_wordpress_migrate_wordpress_blogs() {
// Any key not set here will default to the values set in the
// $blog_default_settings variable in the drush command.
$blogs = array(
array(
'domain' => 'www.example.com/site-one/',
),