Support for versioning for pdf and document assets

Created on 26 February 2024, 4 months ago
Updated 7 March 2024, 4 months ago

Problem/Motivation

In the DAM media content overview view, only DAM - Image media types have "Check for update" as an option under Operations links.

When documents/pdfs use Entity Reference Revisions, there's currently no link for the user to see the previous version. The link uses the external_id, which always points to the finalized version of the asset. Also, when the asset is updated, but the url is not, the previous asset may be cached in the browser.

In the DAM, all the asset types can use versioning, but the Check for Update operation in Drupal is restricted to images.

See repos/acquia_dam/acquia_dam.module

  if ($asset->getDerivativeId() === 'image') {
    $updateUrl = Url::fromRoute('acquia_dam.version_update', ['media' => $entity->id()]);
    $operations['version_update'] = [
      'title' => t('Check for update'),
      'weight' => -1,
      'url' => $updateUrl,
    ];
  }

Steps to reproduce

  1. Add assets of each DAM media type
  2. Go to the DAM media content overview /admin/content/dam-media

Only DAM - Image types have an option for Check for update.

  1. To the Basic page content type, add a field of type Entity Reference Revision that uses DAM PDFs and/or Documents (OR add a wysiwyg field with the Embed media ckeditor button. When embedding media, select Update manually).
  2. Add a Basic page and select a pdf/doc.
  3. In DAM, add a new final version of the asset.
  4. Run cron so Drupal detects that there's a new version.
  5. Update media

For linked text PDFs/documents, there's no distinction in the url for new vs previous versions and there's no thumbnail preview on the update modal.

Proposed resolution

  1. Allow all types of assets to Check for update in the admin UI.
  2. Create a new Embed style for documents and pdfs that renders the media as a link that uses the version id. For downloads: [domain]/content/[version_id]/pdf/[filename]. For viewing: [domain]/content/[version_id]/web/[filename]
  3. Update the "Update media" modal to use thumbnails linked to the appropriate version.

Remaining tasks

  1. Create a new ticket for videos and spinsets.
  2. Update documentation.

Documentation can include an example such as:
Using content moderation for nodes and either an Entity Reference Revision field or an embedded media item that uses the Update Manually configuration in Ckeditor, on an existing, published node using version 1 (v1) of a media asset.

  1. When Drupal detects there's a new version (v2) of the asset, an Update Media button will display on the node edit form.
  2. The editor clicks Update Media and saves the node as Draft/unpublished.
  3. The published version continues to use v1, while the latest version (draft/unpublished) uses v2.
  4. In the case of linked text for pdfs/documents, the v1 and v2 link would have different version IDs in the url.
  5. The node is published and now v2 is used.

User interface changes

In the DAM media content overview, all assets will have Check for Update in the operations dropdown.
For PDFs and Documents, under Manage Display, there will be new Embed Style options and some help text:

  • Text linked to version viewer
  • Text linked to version viewer with download
  • Thumbnail linked to version viewer
  • Thumbnail linked to version viewer with download

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States capysara

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.69.0 2024