1. Ok, I'm going to go ahead and expand the "sites, all" folder again. And we are in the steps directory here. We're going to open up the sixth step, which is called "unmanaged-file-display". Go ahead and copy the entire code and paste it over the code that currently in your assets dot module" file and save it.
2. Ok, I'm going to scroll up to the top of the file and we can start up here at "assets_menu". We've added an item here, called "assets slash unmanaged slash view", so this is the path we can go to to view our display of thumbnails. We're giving it a "title, a "description", and the "callback" is "assets_display_unmanaged_file_page".
3. So let's go ahead and scroll down and take a look at this function. Ok, here we are. We're going to start out by creating an empty string variable.
4. And next we want to set our "directory". So we're in the "public, assets, unmanaged" directory. Now this is the directory where we are uploading our files to.
5. Our next step is to read through that directory and find out what's inside of it and then process the files that we find. We can do this by running a function called "file_scan_directory". This function will take as a first parameter the directory that we're going to scan; and the second parameter, a regular expression that says what we're going to look for in that directory.
6. So for example, we might want to look for just "jpg" files or just "gif" files or just some file of an extension or of a particular name, and we can use this second parameter to pass a regular expression. We're passing it "dot star", which says that we're going to match any character, any number of times. So this will match anything that's in the directory.
7. We can also pass options to it to set a regular expression for items that we don't want to match as well. But we're going to keep this simple. What "file_scan_directory" will return is an array of file objects.
8. Typically, you'd see file objects more with managed files where there's a database entry for the file along with additional data in that files table. But in general, objects are a handy way to encapsulate meta-data about an object, so "file_scan_directory" uses that convention. Next we're going to loop through this returned array and for each one, we're going to build some output.
9. Now remember we're building thumbnails for each one of these, so what we're going to do is just create a wrapper "div", some HTML. We're going to give it a little bit of styling to allow multiple images to wrap so we're using a "float" for that. And then we're calling a "theme" function.
10. Now if you're unfamiliar with "theme", there's a whole section of it in the Drupal seven core concepts videos. But what we're doing is calling the function "theme underscore image_style", by passing as a first parameter the "theme_image_style". And this is a core function that allows us to take an image file and convert it to a particular style.
11. In previous versions of Drupal, this was called "image_cache". In Drupal seven, it's called "image" and it allows us to set the height and width of an image for example, as well as other parameters, such as if we're going to crop it or re-size it. And we're passing it an array of data, including the style name, in this case, it's a core style called "thumbnail", and the path to the file.
12. And notice that we're using the "uri" that's in the file object.