Reader small image

You're reading from  Drupal 10 Masterclass

Product typeBook
Published inDec 2023
PublisherPackt
ISBN-139781837633104
Edition1st Edition
Tools
Concepts
Right arrow
Author (1)
Adam Bergstein
Adam Bergstein
author image
Adam Bergstein

Adam Bergstein is a product engineering leader and an architect. He has been a long-time Drupal community member, a routine speaker at Drupal community events around the globe, and provided keynotes for several events. He has maintained and contributed to many Drupal projects, including Password Policy, Taxonomy Menu, and more. Adam is the lead of Simplytest, a free service, and a project that offers Drupal community members testing sandboxes. He has also worked for both agencies building Drupal applications and Drupal service providers building Drupal-related products. He has led the Drupal Community Governance Task Force and is serving a term as a community board member of the Drupal Association.
Read more about Adam Bergstein

Right arrow

Files, Images, and Media

Drupal’s File and Media systems provide a rich set of features that are commonly used for static assets, such as images, videos, and more. This chapter extends structured content concepts to files and media types and leverages these features as fields linked to other entities. Each feature has various ways to configure both media and files. This chapter covers additional use cases, including Drupal’s public and private filesystems for different storage mechanisms. Finally, this chapter concludes with various tutorials that address common asset-based implementations.

In this chapter, we’re going to cover the following main topics:

  • Assets in Drupal
  • Files
  • Images
  • Media
  • Use cases

Assets in Drupal

Assets are a specific type of digital content. Consider reading about a researcher online. When viewing their biography on a University website, an image shows a picture of them, a list of their publications, which are linked to PDF files, and a video of their latest conference talk is featured. These are all assets.

Assets are a vibrant part of the modern web. Social platforms such as Instagram and YouTube are built around images and videos. The emergence of cameras and cell phones has made digital assets ubiquitous. As such, assets are a large part of digital applications. And, assets are a significant part of Drupal.

Use cases

Assets are one part of the longstanding “trifecta” of Drupal: code, database, and files. Files take on two forms: assets and generated files. Configuration, as an example, is generated by the Drupal application, managed by the runtime database, and persistently stored in files for versioning. Drupal’s caching...

Files

The foundational asset management feature in Drupal is called File. This feature handles fundamental file management for Drupal’s assets.

Subsystem

File has an entire subsystem in Drupal. Like several other systems, it starts with a File entity. This entity provides all of the standard CRUD operations for files. This entity maintains all of the file storage and the corresponding metadata for a file. Supporting the entity are all of the functions that help derive file size and file extensions, and also perform file uploads during content authoring. At a high level, the file subsystem performs basic asset storage, retrieval, and management capabilities.

Entities leverage files through the use of a file field. Suppose that the content of a particular content type should have an attached file. A file field can be added to the structured content of the content type, which then allows you to upload a file and associate it with the node. Files uploaded to the public...

Images

Images represent a specific type of file and more specific functionality. Images build those specific features by leveraging files for all of the foundational asset-related functionality, such as CRUD. It also adds image-specific metadata, such as fields for alternate text, which is helpful for accessibility. Drupal may have content that links to a PDF or Word document that was created outside of Drupal. However, web browsers have native support for images of various formats. Given that Drupal serves content for the web, it offers more advanced image-related features beyond simple file linking, which is useful for rendering images and transforming images as part of its content management capabilities.

The responsive web adds more demands on content management systems to ensure images are appropriately delivered to different devices. Some images can be rather large in file size. Imagine the earlier days of cellular networks trying to download a large image on a web page. Content...

Media

Media extends both files and images to provide more centralized management of digital assets and perform greater integrations across assets managed by Drupal and assets managed outside of Drupal. This centralized management offers a different experience for managing assets and structured content. Out of the box, media works well with files and images but has tools such as oEmbed to work with remote, third-party assets such as YouTube, Instagram, and more.

The media framework provided by Drupal allowed the community to produce a vast ecosystem of media-related modules found on drupal.org. Media has been extended for Google Docs, Spotify, social networks, and much more. The framework allows media sources for custom systems, which, in turn, allows Drupal to integrate media throughout an enterprise.

Media types provide a structured, fieldable entity type for digital assets and metadata. A media reference field offers integration with other entities that can associate specific...

Use cases

Files, images, and media can be used in different ways and are exemplified in the following use cases.

Creating research papers

Suppose that researchers are Drupal users who can highlight their publications in the content management system for their academic institution. A researcher can also be a user role in Drupal, which allows for fine-grained access control of that persona. This use case can be completed by linking file fields to the research papers content type. Most research papers are published as PDF files, not images or videos. Follow these steps to perform the site building that’s needed for this use case:

  1. Create a research paper content type under admin/structure/types/add.
  2. Add a file field to the new content type that’s restricted to PDF file extensions.
  3. Manage the display of the research papers content type to create a teaser display that provides a simple link to the research paper file field.
  4. Grant the researcher role...

Summary

Digital assets have become an integral part of content management, especially as mobile phones have become more ubiquitous. Content management has had to better support photos and videos and integrate with third-party services, such as social media, that readily incorporate digital assets. Drupal affords a customizable experience through its files, images, and media features, all of which address these use cases. Files provide the foundation for Drupal to manage an asset. Images help offer specific capabilities, such as image styles and responsive images, that provide more targeted content management. Finally, media helps offer tools for a more robust structured content mechanism and refined experience that helps you manage digital assets more broadly.

In the next chapter, we’ll learn how to implement search within Drupal.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Drupal 10 Masterclass
Published in: Dec 2023Publisher: PacktISBN-13: 9781837633104
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime

Author (1)

author image
Adam Bergstein

Adam Bergstein is a product engineering leader and an architect. He has been a long-time Drupal community member, a routine speaker at Drupal community events around the globe, and provided keynotes for several events. He has maintained and contributed to many Drupal projects, including Password Policy, Taxonomy Menu, and more. Adam is the lead of Simplytest, a free service, and a project that offers Drupal community members testing sandboxes. He has also worked for both agencies building Drupal applications and Drupal service providers building Drupal-related products. He has led the Drupal Community Governance Task Force and is serving a term as a community board member of the Drupal Association.
Read more about Adam Bergstein