2

I am very new to Craft CMS and going through the introduction videos on Mijingo. I am new developer also so please answer in easy terms if you can. I need to know what the difference is between an image I might drop straight into the assets file (if I choose) or the uploaded ones through Craft. I understand that you want to use images in the CMS they NEED to be uploaded through Craft. BUT why would you use "static" images straight into the assets file? My colleague said if you want to use interface pictures you drop them straight in. But I don't understand what that means. Thanks very much and have a great day.

Jason

P.S. Please say why if this was a bad question so I can become better at asking on Stack Exchange. Thanks again!

  • Static images are the most good way of storing images and the static images also good for use.I am also use static images. – Alvina Jennifer Oct 18 '17 at 13:12
4

Great question! Let's define some terminology to make this easier to discuss...

  • Static images: Uploaded via FTP (or similar). Not tied into the CMS in any meaningful way.
  • Dynamic images: Uploaded via the Control Panel (or synced after FTP upload). Can easily be related to entries and other elements, or even have fields assigned directly to your assets.

Static images are the more "traditional" way of storing images, just as you would with a non-CMS website. There are absolutely some good reasons to use static images... for example, anything on your website which will basically never change (like the company logo).

Dynamic images (aka "Assets") are ideal for dynamic content. If you're writing articles with images, this is a perfect use-case. There are far more complex examples as well, but this is a great starting point.

If an image makes more sense being static, then let it be static. Conversely, if you believe it needs to be dynamic, then make it dynamic. Don't try to force an image to be something that it's not. With just a little bit more experience, it will quickly become obvious which kinds of images should be static vs dynamic.

Here's how I've got my folder structure setup...

/craft
/public
    /assets
        /(ASSET SOURCE FOLDER 1)
        /(ASSET SOURCE FOLDER 2)
        /(ASSET SOURCE FOLDER 3)
    /resources
        /css
        /js
        /images

My static images go into /public/resources/images. They are then referenced just as if the site were not using a CMS at all.

My dynamic images go into various subfolders within /public/assets. Each subfolder maps directly to an Asset Source, defined in the CMS control panel.

NOTE:

Make sure your assets subfolders have proper read/write permissions! Craft will need to interact with those files when uploading, and also when creating image transforms.

Permissions for your static folder can be much stricter... Those will only need to be read, never written to.

Of course, this all assumes that you're storing your dynamic images in a local folder... Things are slightly different when you want to keep your assets in the cloud (S3, Rackspace, Google), but that's a different conversation altogether.

Hope that helps!

  • 1
    Another reason to use a static image: you refer to it in your css. – Marion Newlevant Jul 23 '15 at 16:32
  • @MarionNewlevant Great point! – Lindsey D Jul 23 '15 at 16:40
  • Thank you Lindsey D very much. Very clear! Sorry it took so long to vote and accept...I went on vacation. Jason – Jason Sep 9 '15 at 7:48
2

Can't speak for anyone else, but I have an img and a fonts directory in my public directory, where I put static image files and fonts.

One positive about putting it in the assets is that you have transforms available for them, and you can attach metadata if you want to. There might be performance implications to it though, but I can't imagine that would matter unless you have a lot of traffic.

I've made a Yeoman generator to quickly scaffold everything (directory structure, build system, commonly used frameworks). It's using Grunt for builds, and packs everything into a nice little tarball that you can move when you need to deploy it.

1

For me, it usually breaks down like this:

Static assets are unrelated to the content of the website. They are design related. Dynamic assets are content. They have meaning.

/craft
/public
  /assets (The website design, these are all static)
    /css
    /images
    /fonts
  /content (Stuff uploaded through Craft by users, all dynamic)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.