58BITS
  • Home
  • Tech Stuff
  • Other Stuff
  • Photos
  • About
  • Contact
58BITS
  • Home
  • Tech Stuff
  • Synchronizing Default Images for Image Fields...

Synchronizing Default Images for Image Fields in Drupal 8

Submitted on Apr 13, 2016, 2:38 p.m.

The new Configuration Management  system in Drupal 8 is excellent. When combined with our current Git/Capistrano  workflow, it means that all content type and view definition changes can be exported to the configuration 'sync' directory, committed to source control, and pushed to the target deployment site (staging, production etc.).

In our case settings.php for the development and target sites have been updated to use a sync directory that's outside of the site root.

A typical commit and deployment cycle looks like this:

# From the dev or staging area
drush config-export # Export configuration changes since last run
git add -all # Stage all the changes
git commit -a # Commit (with a decent commit message)
cap production deploy # Deploy with capistrano
# On the target server
drush config-import -y # Import configuration changes for this deploy

It all works very well and is a huge improvement over previous solutions, including using the Features module, or manually exporting and importing views.

However, one gotcha I recently discovered, was 'default images' on image fields. You could argue that these are part of configuration, but the images themselves are stored using unique UUIDs via the content management system's file management subsystem.

And so here's a recipe for 'fixing up' default images.

  1. Add a default image to your image field as you normally would and save the updated content type definition.
  2. Export the configuration changes and push these to your target site. You'll notice that the default images don't appear on the target site, because they're not present in the managed file system.
  3. Go ahead and re-create/re-add the default images to the 'live' or 'target site' - just once
  4. Once the default image(s) have been added, you'll need to fixup the UUIDs of the images to match the UUIDs of your development setup. On the local development site execute the following MySQL query: select * from main_file_managed \G; and make a note of the UUID and fid for the default image.
  5. On the target site, execute the same MySQL query select * from main_file_managed \G; and make a note of the fid and UUID for the default images there.
  6. On the target site update the UUID for the default image to match the source development site. For example update main_file_managed set uuid='6b78ffde-3ede-4c88-af45-53ab2c20a362' where fid=27;
  7. Here's the important part. Now go ahead and run the drush config-import -y again on the 'target' site - and all should be well. You only have to do this once and all future configuration synchronizations will be fine, and the default images will remain in place.

Hope this helps...

Featured

ความเสี่ยงที่เกี่ยวข้องกับเทคโนโลยีหน้าจอสำหรับเด็ก (วัยก่อนรุ่นและวัยรุ่น)

ความเสี่ยงที่เกี่ยวข้องกับเทคโนโลยีหน้าจอสำหรับเด็ก (วัยก่อนรุ่นและวัยรุ่น)

Sep 15, 2024, 10:53 a.m.
An Executive Summary of the Current State of AI

An Executive Summary of the Current State of AI

Jul 20, 2024, 5:45 p.m.
Digital Media Preservation - Why Media Organizations Can’t Archive

Digital Media Preservation - Why Media Organizations Can’t Archive

Sep 17, 2012, 11:59 a.m.
The Long Road Home

The Long Road Home

Nov 09, 2011, 8:12 p.m.

Latest

อันตรายที่ซ่อนเร้นของน้ำตาล: ผลกระทบต่อสมองเด็กและสุขภาพผู้ใหญ่

Nov 27, 2024, 2:36 a.m.

General Purpose Encrypt and Decrypt Functions with Jose

Sep 16, 2024, 11:19 p.m.

ความเสี่ยงที่เกี่ยวข้องกับเทคโนโลยีหน้าจอสำหรับเด็ก (วัยก่อนรุ่นและวัยรุ่น)

Sep 15, 2024, 10:53 a.m.

Migrating a Google Workspace Account to a Personal Google Gmail Account

Aug 04, 2024, 9:30 p.m.
58bits

Tech, art, and life...

Copyright © 2026 Anthony Bouch. All rights reserved.

Made with ❤️ by Infonomic

Explore
  • Home
  • Tech Stuff
  • Other Stuff
  • Photos
Legal
  • Terms of Use
  • Privacy Policy
  • Cookies
Connect
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Copyright © 2026 Anthony Bouch. All rights reserved.

Made with ❤️ by Infonomic

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.