We use cookies to make your viewing experience better. By accepting you consent, you agree to our Cookie policy

Accept
Improve your Craft CMS skills

Understanding Craft CMS And Assets

10 min read
Shape April 2022 HR 45

Managing digital assets is a major pain point for modern web projects. With ever growing multimedia libraries, organizing, transforming and outputting images, docs and files becomes complex. This guide will walk through how Craft CMS solves these asset management headaches. Learn to streamline workflows, leverage smart image transforms, enhance security and more using Craft’s robust, developer-friendly asset tools.

Craft CMS offers developer-friendly tools to optimize asset management including organizing with metadata and custom fields, transforming images, securing permissions, version control, automating workflows, and leveraging volumes for large multimedia libraries.

Understanding Craft CMS and Key Capabilities

Overview of Craft CMS

Craft CMS is an open source PHP content management system that is built on the flexible Yii framework. Embracing an MVC architecture, Craft neatly separates concerns between templates that provide views, modules and plugins that enhance controllers and models, and an intuitive control panel for content creators to manage entries. This modular approach makes Craft highly customizable and extensible.

Some of the standout features of Craft CMS include user-friendly editing capabilities in the control panel, powerful Twig templating engine, native support for custom fields and content types, robust localization capabilities, and a flourishing plugin ecosystem.

The control panel offers spreadsheet-style inline editing that allows content editors to efficiently manage entries. For developers, Twig templates enable full programmatic control over frontends with inheritance, components, and macros facilitating reusable code. Custom fields and matrix content blocks model complex, structured data. Out-of-the-box localization features mean Craft can power translated multi-lingual sites. Finally, plugins extend functionality ranging from user management to API integration and beyond.

In summary, Craft provides a flexible and extensible framework for developers to build customized CMS solutions. Meanwhile, it empowers content creators with an intuitive editing interface. This caters perfectly to the needs of both audiences.

Managing Multi-Site Setups with Craft

Craft enables managing multiple sites from a single codebase and database. This streamlines efforts for larger websites that benefit from shared data and translations across sites while still allowing customization for each one.

Craft offers site-specific configuration options including settings, handles, languages, and custom fields. Routing rules match requests to appropriate sites based on domains, subdomains or URL paths with support for wildcards.

Content can also be managed on a per-site basis. Entries, categories, global sets and other elements can be selectively made available to certain sites. User permissions and groups give control over access on a site level as well.

For the frontend, unique templates can be used for individual sites enabling tailored designs and layouts. Template inheritance promotes reuse of common elements across different sites. Sites can also have their own primary domains as well as additional aliases, with flexible rules for handling redirects.

With multi-site capabilities, Craft enables starting simple and scaling up to complex multinational, multi-lingual websites from a single codebase. Duplication of efforts is eliminated while still facilitating customization between sites.

Craft's Flexible Content Modeling

Craft provides extensive options for creating customized content structures tailored to specific needs.

Matrix fields allow grouping multiple content blocks within entries, useful for reusable components like testimonials or intersecting data sets. Table fields manage tabular data or repeating items such as product specifications. Neo fields enable creating node-based relationships between content entities like organization charts.

Global sets provide reusable content fragments shareable across entries and sites. Modular entries compose types by combining standard and custom fields in novel arrangements. Relationships connect entries in hierarchical structures or more flexible connections like entry linking.

Beyond standard fields, custom fields can be created with specialized validation and formatting for unique content needs. With these modular blocks, Craft enables building unlimited content models and relating complex information architectures.

The flexibility of Craft's content modeling caters perfectly to creating structured data that fits a project's custom requirements. Intuitive editing empowers content creators to manage structured content effectively.

Digital Asset Management with Craft

Asset Volumes for Organizing Files

Craft allows organizing digital assets into separate volumes with permissions and rules tailored to each one. This provides a flexible way to structure files for different projects, clients or purposes.

Volumes operate as isolated containers for assets. Each volume gets its own:

  • Permissions - Control which user groups can view, upload, edit or delete assets in that volume.

  • Access rules - Set criteria like allowed file types or maximum upload size at the volume level.

  • View settings - Customize image sizes generated, restrict transforms, etc. per volume.

Some use cases for multiple volumes include:

  • Separate volumes for client work to limit access. A volume per client with permissions set accordingly.

  • Internal assets versus public assets used on the front-end site. Limit external access to only finished assets.

  • Temporary project work versus permanent image archives. Set an expiration date for obsolete volumes.

  • Different formats or types like PDFs versus videos in their own volumes. Control file type restrictions at the volume level.

With strategic use of asset volumes, files can be logically organized for projects of any scale in a flexible and customizable manner. Manage permissions granularly while also applying specific rules as needed per volume.

Uploading and Managing Assets in Craft

Craft offers user-friendly management of asset uploads directly in the control panel. Files can be uploaded via browser uploads or drag-and-dropped for convenience.

Uploaded assets land in a global volume by default but can be moved to any volume available to the user. Within volumes, assets can be further organized in:

  • Folders - Hierarchical folders and subfolders to categorize assets.

  • Recent files - Quick access to files uploaded in the last few days.

  • Unsorted files - Assets not placed in folders land here.

Additional handy asset management functions include:

  • Bulk actions - Apply operations like moving or deleting on multiple assets simultaneously.

  • Renaming files - Change file names directly in the asset manager.

  • Viewing details - See useful metadata like format, size, image dimensions without opening the file.

  • Moving - Click and drag assets around to different folders or volumes with ease.

With its user-friendly browser asset manager, Craft takes the friction out of organizing and maintaining large volumes of digital files needed for modern websites.

Adding Metadata to Assets in Craft

Craft allows attaching extensive metadata to each asset for enhanced organization. Metadata fields include:

  • Title - A short title or caption for the asset.

  • Description - A long description conveying details that may not be obvious from the asset alone.

  • Tags - Keywords to categorize the asset. Useful for contextual searching and filtering later.

Beyond these default fields, custom fields can also be attached to assets. For images, useful examples may include:

  • Location - For photographic images, where the photo was taken.

  • Credit - Name the image creator when known.

  • Copyright Info - Any needed copyright or attribution info.

For documents, audio, video and other files, relevant metadata could include:

  • Transcript - For video/audio assets, a text transcript.

  • Author - Document creator.

  • Version - Latest revision for editable assets.

With strategic use of titles, descriptions, tags and custom fields, assets become much easier to organize at scale. Metadata also powers advanced searching and filtering of assets in the control panel. For example, quickly find assets missing titles or filter by custom fields. This brings a new level of maintainability to digital asset management in Craft CMS.

Transforming and Outputting Images

Image Transforms in Craft CMS

Craft CMS provides extensive capabilities for transforming images on the fly to output optimized versions for responsive sites. With its flexible transform settings, developers can dynamically resize images for various breakpoints, create thumbnails and crops for previews and listings, optimize formats, and more. Transforms tap into the power of on-demand image derivation - new versions are generated lazily only when needed. This maximizes caching potential and performance.

By handling transforms natively rather than an inefficient workaround like manually exporting resized copies, Craft unlocks new levels of flexibility. Need a new thumbnail size? Simply define the transform settings and templates will have access immediately. Images can be automatically cropped around key focal points and faces for ideal compositions. Output multiple sizes for mobile, tablet and desktop layouts that maintain sharpness regardless of resolution. Convert between formats like JPG and PNG as appropriate for each image. The possibilities are vast for handling any image-related requirement in a dynamic site build.

Retrieving Assets in Templates

Outputting assets in Twig templates leverages the seamless integration Craft offers. Images on entries are accessed directly via variable handles. The asset query builder retrieves assets by ID or other criteria. For-loops output images in matrix blocks or other relations. Global set images are grabbed as models for further manipulation. The asset URL or transform methods ready images for output in HTML or markup. By combining Twig tags, variables, and Craft asset functions, templates unlock the complete power of assets.

Optimizing Images for Web Performance

A major benefit of Craft is its native image optimization that results in lightning-fast load times. Setting appropriate compression levels minimizes file size with limited perceptible quality loss. Responsive transforms resize images to only the pixels needed for each breakpoint. Configuring caching via headers or the web server enables repeat visits to be served from disk. Choosing the right web formats like JPG and PNG avoids less optimized options. Lazy loading defers offscreen image loads until scrolling.

The combination of smart transforms, compressing, resizing, caching, and other techniques means Craft is optimized for performance right out of the box. Developers can leverage these tools to easily build responsive images that load at maximum speed for their sites without extra work.

Advanced Asset Management with Craft

Securing Assets in Craft CMS

Craft provides powerful tools for controlling access to assets. Permissions can be set at both the volume and individual asset level.

User groups assigned to each volume dictate uploading, viewing, editing, and deletion abilities. Limit volumes to only authorized users.

Specific assets can also get custom permissions. For example, make an asset viewable only by certain user groups.

Other security considerations include:

  • Remove script access to volumes to prevent direct asset access.

  • Utilize private assets with security tokens if assets should not be publicly accessible.

  • Generate image transform URLs that are one-time use only.

  • Integrate a plugin like Protect Files for advanced permission rules.

With its permission layers and security options, Craft enables configuring an environment where assets are secured from unauthorized access or direct exploitation.

Automating Asset Workflows

Mundane asset management tasks can be automated in Craft to save time and effort. This frees creators up for higher-value work.

  • Use image editing plugins to automatically optimize images on upload. Compress, resize, and enhance uploaded assets without lifting a finger.

  • Integrate external processing services via webhooks that fire on asset save. Automatically send newly uploaded images for editing by AI tools.

  • Build custom workflows with Craft or Yii to programmatically manipulate assets on certain triggers. Automatically categorize assets based on metadata and file details.

  • Take advantage of external data sources like image CDNs that can handle transformation and image processes directly with their API. Streamline asset derivatives.

  • Leverage Crafty for visual workflow building without code. Connect asset management steps with business logic.

Automation enables assets to be processed and optimized to business needs programmatically. This takes the manual effort out of repeatable tasks.

Version Control and Rollbacks

Craft maintains the full history and versions of assets for rollback capabilities:

  • Upload new versions of assets while preserving old ones. Quickly update images while maintaining previous states.

  • View the version history of an asset to see all uploads, changes and deletions in timeline format.

  • Restore previous versions of assets if needed. Rollback from bad changes or recover lost versions.

  • Retrieve deleted assets by exploring the volume's trash. Assets are soft-deleted for recovery.

  • Compare versions visually for images. Spot the subtle differences between asset versions at a glance.

  • Backup or migrate asset version history across environments. Preserve the full timeline through launches and migrations.

With the ability to easily revert mistakes and restore missing assets, version control provides peace of mind over precious media libraries.

Shape April 2022 HR 202
Andy Golpys
- Author

Andy has scaled multiple businesses and is a big believer in Craft CMS as a tool that benefits both Designer, Developer and Client. 

Share
Feedback
Show us some love
Email Us
We usually reply within 72 hours
Agency Directory
Submit your agency
Affiliate Partners
Let's chat