Skip to content

Remove absolute URLs from images in block markup #161

@mikachan

Description

@mikachan

It would be great if this plugin could remove absolute image URLs from images in block markup, either on export or via a separate button somewhere.

Currently, any images that are inserted into a template need to have their URLs manually changed to be relative to the theme directory in order for them to be successfully used outside of the build context (i.e. the local environment or dev environment where the site is being built).

For example, changing an image URL like this:

<!-- wp:cover {"url":"https://localsite.com/wp-content/uploads/2022/12/imagefile.png"...

To this:

<!-- wp:cover {"url":"<?php echo esc_url( get_stylesheet_directory_uri() ) . '/assets/images/imagefile.png'; ?>"...

The above solution would require the template file to be converted from HTML to PHP. It would be good to hear if there's a better way!

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions