How to properly change / add to CP HTML I'm making a change to the CP so that clicking an asset thumbnail from the asset preview HUD will open the asset in a new tab. Specifically, I'm changing line 1685 of craftcms/cms/src/elements/Asset.php to this:
&lt;/div&gt;&lt;a href=&quot;' . $this-&gt;url . '&quot; target=&quot;_blank&quot; style=&quot;width:100%;height:100%;position:absolute;&quot;&gt;&lt;/a&gt;';
This achieves what I want, but it's obviously not the right way to do it. My question is, what is the right way? Can I do this with a module as opposed to a full plugin?
The only feasible way of doing this without it being overwritten in each Craft update is by manipulating the elements using JavaScript. You can of course do this using your own module or plugin, but an easier approach would be to use the Control Panel JS plugin, which was created specifically to allow you to add JavaScript in the control panel.