Handling CDN images in Sage 11

Hey all,

I’m using Imagekit for hosting my images and I’m trying to figure out the best way to access them in my blade templates. Is this a job for Vite, acorn, handle directly in Sage as a function, or Acorn? There seems to be multiple ways to achieve this but nothing is noted or even suggested in the docs Help me find a path!

Do I manually add that file to my theme(sage)? Then overwrite the url key?

Ok, I have tried to install acorn and broken my local development instance. I’ve put in the code into my functions.php and now I just get the error that acorn is not installed.

This is my require fields in composer.json in my Sage theme

  "require": {
    "php": ">=8.2",
    "log1x/sage-directives": "^2.0",
    "roots/acorn": "^5.0"
  },
 

what is now happening???

And I can’t ssh into my vm

trellis % trellis ssh development
Running command => ssh [email protected]
[email protected]: Permission denied (publickey).
Error running ssh: exit status 255

why is everything breaking, I’ve done nothing to vm except start and stop it. How am I breaking it?

Hi. You should of only had to create a config folder in your theme and copy over the file that Ben linked. Sage 11 otherwise already has Acorn booted in functions.php.

ok, I’ve taken out the acorn code from my functions.php and I have my site running but I still don’t know how I use acorn to render my images in a blade template. I’ve have the config but I can’t find anything in the Acorn or Sage docs about using images? What am I calling to use that manifests → theme → url?

I’m not familiar with Imagekit. It looks like they have a PHP SDK as well as a WordPress plugin – looking at step 2 of the WordPress plugin:

If your old image URL was https://www.example.com/wp-content/uploads/image.jpg, then the same image should be accessible through ImageKit.io URL-endpoint, i.e., https://ik.imagekit.io/your_imagekit_id/wp-content/uploads/image.jpg

I assume if you access an image with something like wp_get_attachment_image() – Function | Developer.WordPress.org their plugin will automatically filter the URL appropriately. This wouldn’t really be related to Sage or involve anything with Vite/Acorn unless you are trying to offload your compiled assets. If you were offloading your assets and needed to adjust the endpoint URL, that’s when you’d pull in and configure config/assets.php.