How can File block options be set to Off by default?

Created on 5 March 2023, almost 2 years ago
Updated 5 June 2024, 7 months ago

For a Gutenberg file block, the "Show inline embed" (for PDF files) and "Show download button" options are on by default.

Is there a way to change these defaults to off?

✨ Feature request
Status

Active

Version

3.0

Component

User interface

Created by

πŸ‡ΊπŸ‡ΈUnited States brianbrarian

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States rpayanm

    You have to create a module like you are building a new gutenberg block:

    and inside your index.es6.js paste this:

    const { addFilter } = wp.hooks;
    
    addFilter( 'blocks.registerBlockType', 'name-of-your-module/extend-file-block', function (settings, name) {
      if (name === 'core/file') {
        settings.attributes.showDownloadButton.default = false;
      }
      return settings;
    });
    
    npm run build
    

    and it is done.

  • πŸ‡ΊπŸ‡ΈUnited States brianbrarian

    Thanks, @rpayanm! That will get me started.

  • πŸ‡ΊπŸ‡ΈUnited States brianbrarian

    I'm finally getting back to this, and am changing this issue from a support request to a feature request.

    The devs I work with were able to change the default setting for "Show download button" to off, so that part has been resolved for me, but changing the default setting for "Show inline embed" for PDFs to off doesn't appear to be possible.

    I was told by my devs that the option for an "off" default needs to be provided by the WordPress Gutenberg project first. See this WP issue: https://github.com/WordPress/gutenberg/issues/34825

Production build 0.71.5 2024