Dude, where are my images?

So you’ve copied some images somewhere in Orchard’s media folder, but they are not showing… What’s going on? If no media are showing on the site, chances are you’re missing a web.config file under the media folder. Put one in there. If the images are only missing from the Media section of the admin, then the problem is that you’ve created orphan media.

Since Orchard 1.7, media are content items, which opened up a lot of interesting scenarios. As a consequence however, the presence of a file on disk in the media folder is not enough to make it available in the media library: if there is no associated content item, it won’t show. That means that if you uploaded the file to your site using ftp, or copied the file, you’re out of luck. The media uploader integrated in the media library is actually very efficient and user friendly, and using ftp in comparison looks a little “last century”. Next time, save yourself the trouble and use it ;)

The mistake can still be fixed. When Orchard 1.7 shipped, we needed a migration path, that transforms old media files to media + content item pairs. Fortunately, that migration still ships with subsequent versions of Orchard, and can still be used, repeatedly, without any bad consequences.

Go to “Modules”, then enable the “Upgrade” feature. Once this is done, you’ll see a new “Upgrade to 1.x” menu item near the top of the admin menu. Click it, then select the “Media (1.7)” tab. You should see something like this:The media migration screen

Click the “Migrate” button. After a few seconds (depending on how many orphan files you have), the migration is over, and all your media are now content items that will appear in the media section. You may disable the feature.

Arguably, this should be a little easier. I think we should have a button in the media library that enables the user to see orphan files, and then create content items for them (a little like the the "show all files" button button in Visual Studio’s solution explorer, together with the “include in project” context menu item).

4 Comments

  • Or a Media Provider (like the 3 default ones we have) which would do exactly that, show what files are not available as content items, and does the import.

  • Ooh, good idea, that way it can be a gallery module.

  • In fact, even orphan images are accessible from Web, only Media library cannot show them. FTP is the only solution in case of really big files, given the fact that none can risk to increase upload file size to something large.

  • Yes, which is why I said " If the images are only missing from the Media section of the admin". As for "really big files", what size are we talking about?

Comments have been disabled for this content.