asset('assets/img/stuff.svg')->mediaUrl()

Is this supposed to work?

<?php 
$src = asset('assets/img/stuff.svg')->mediaUrl();
<img src="<?= $src ?>" alt="Stuff">

<pre>
<?= $src ?>
</pre>

The media url comes out like:

http://localhost/media/assets/assets/img/769830240-1667553438/stuff.svg

And the image doesn’t load.

If possible I’d like to use it for the built in cache busting fingerprint path. Do I have to manually copy the file into the media folder, and if yes, is there a more convenient way of doing this than:

  $file = asset('assets/img/logo.svg');

  if($file->asset()->exists() && !F::exists($file->mediaRoot())) {
    F::copy($file->root(), $file->mediaRoot(), true);
  }

Maybe something that does it asynchronously via a .jobs file?

Hm, I wonder if this actually makes sense. The mediaToken used for the mediaHash is based on the page folder and an assets from the assets folder doesn’t have a parent page.

Well, the second part of the 769830240-1667553438 is the modified timestamp of the file…
I mean, I also could do a <?= $file->url() . '?t=' . $file->modified() ?> , but I’ve heard that adding query parameters for cachebusting isn’t ideal.

As far as I know, jobs are only created for thumbs. I don’t think, are not used when the original file is copied to the media folder (might be mistaken).