I am new to Drupal 8. I am building a website with Drupal 8, and it has many blocks contain images. They have an absolute path for the src attribute right now. I would like to make them dynamic base on the base URL, but there is no text format support PHP code anymore for security reason. Is there a safe way to achieve this?
You could and should do your PHP logic with template_preprocess_block. As creating a programmatic block just so you can use PHP is more work than necessary, overkill, for this use case.
Also, without any more specific info regarding
make them dynamic based on base URL, this is as far as I can go.
PHP filter is a core module in Drupal 7 but in Drupal 8 it is removed because of some security reason but still you can use this module PHP.
Note: Enabling this module can cause security and performance issues as it allows users to execute PHP code on your site.