Drupal, Lando, S3FS module, and Image Styles

The bug: Image styles don’t generate (they all return 404) when using the following:

So you’ll need to override lando’s default vhosts file. You can do so by doing the following in your .lando.yml file.

name: projectname
recipe: drupal9
config:
  via: nginx
  config:
    vhosts: lando/default.conf

Then you’ll need to create a file in your app root lando/default.conf . To start, you can go to the lando/drupal recipe page , go into the recipe you’re using, and then copy the default.conf.tpl into your lando/default.conf file.

Next, locate the following snippet:

  # Fighting with Styles? This little gem is amazing.
  # location ~ ^/sites/.*/files/imagecache/ { # For Drupal <= 6
  location ~ ^(/[a-z\-]+)?/sites/.*/files/styles/ { # For Drupal >= 7
      try_files $uri @rewrite;
  }

And replace it with the following snippet (only regex is changed)

  # Fighting with Styles? This little gem is amazing.
  # location ~ ^/sites/.*/files/imagecache/ { # For Drupal <= 6
  location ~ '^(/[a-z\-]+)?/sites/.*/files/styles/|^/s3/files/styles/' { # For Drupal >= 7
      try_files $uri @rewrite;
  }

I also opened a GitHub issue in case someone on the project wanted to commit back to the project. I may get around to it if I have time.

Hope this helps. I spent a couple hours on this since I didn’t know why my image styles weren’t generating and I couldn’t find anyone else that was running into the same problem. Good luck!

WordPress, New Server, and “Unable to create directory”

I recently had to move my blog from WebFaction (who was bought out by GoDaddy and then eventually shut down their services) to Digital Ocean.

I couldn’t upload files for the longest time and kept messing with file permissions as recommended from all the different Google searches I did. And nothing was working.

Turns out, my server was configured properly, but I forgot to change the Store uploads in this folder value via WordPress dashboard when I switched webservers at /wp-admin/options-media.php.

Change this value to the server’s new value!!

Hopefully this helps someone else.

Drupal 8, Smartling TMGMT, and Local Development

If you use Smartling for translation management and it’s all setup for production, here’s how to override those values on your local development environment to download pseudo-translations for easier debugging if you don’t need to test actual translations.

Add this to your settings.local.php:

// Force to always download pseudo translations (altered strings).
$config['tmgmt.translator.smartling']['settings']['retrieval_type'] = 'pseudo';

// Whether to skip the TMGMT review process after downloading. Set to TRUE to skip, FALSE to not skip.
$config['tmgmt.translator.smartling']['auto_accept'] = TRUE;

Migrating Drupal 7 Image Files to Drupal 8 Media Images (no PHP required!)

I’m new to migrate. And it’s a beast. But I think after a few dozen hours of diligence, I think I’ve figured out my preferred method.

This post is for someone who already understands how to use views, develop custom modules, and knows how to use drush migration operations.

I originally tried using migrate_drupal, which honestly did a great job at migrating my user roles, users, and taxonomies. But the site I am migrating is 5 years old with a good amount of technical debt having been touched by over 10 (and maybe even 20) developers over its lifetime, so I think it’s time for a fresh start. I want to migrate everything else (content types, files, etc) manually.

All the Drupal 7 content types were using image (file) fields, but I want the new Drupal 8 site to use media fields. I couldn’t use the migration provided by migrate_drupal, so I had to get creative.

This will be a two step process:

  1. Use D7 views_datasource module to create JSON endpoints on my old site (and since we’re using a JSON source, you can honestly migrate from anything).
  2. Write a custom migration in D8.
Read more