Jump to:

23001 Posts in 11702 Topics by 2827 members

General Questions

SilverStripe Forums » General Questions » Cleaning out the assets folder

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2
Go to End
Author Topic: 769 Views
  • Futureweb
    Avatar
    Community Member
    232 Posts

    Cleaning out the assets folder Link to this post

    Hi,

    I manage a few sites which are quite old, and where the assets folder contains over a gig of files which the client has been uploading into for years.

    What i'm looking for is a module which lists all the files in the assets area, the file sizes, date uploaded, and how many times this file is used (eg, linked to either through has_one with a database, or linked into the html content of a page)

    Then, either through script, or manually, the client would be able to delete their old files, and make the whole site a lot easier to manage.

    Does anyone know if such a module exists?

    Cheers

  • Stef87
    Avatar
    Community Member
    66 Posts

    Re: Cleaning out the assets folder Link to this post

    Hi

    I haven't used this so I'm not sure if it does exactly what you want but here's a link anyway.

    http://www.silverstripe.org/versioned-files-module/

  • zenmonkey
    Avatar
    Community Member
    524 Posts

    Re: Cleaning out the assets folder Link to this post

    I know SS3 does a much better job at tracking backlinks for files. I'm getting to this point with one of my clients SS2.x and dreading tackling it because I need to move it to a new host.

  • feejin
    Avatar
    Community Member
    22 Posts

    Re: Cleaning out the assets folder Link to this post

    SS3 seems to track images used in UploadFields but in HTMLEditorFields SS3 images and files are inserted as HTML with their URLs. It would be good if these were replaced with database IDs like how page links are done so it had a means of saying if / where / how often an image was used.

  • zenmonkey
    Avatar
    Community Member
    524 Posts

    Re: Cleaning out the assets folder Link to this post

    I'm just going off the top of my head so it's totally hacky, but I guess you could do a custom controller that loops through all file objects, then searches all the content fields (on Page + any custom DataObjects with HTML Content) for a version of the $Name field stripped of the extension. Uou could then check and relations as well. If the search returns no results it deletes the object. Not an efficient function but theoretically you'd only run it occasionally, and probably manually.

    Like I said hacky, but hey I'm writing this while eating lunch

  • Futureweb
    Avatar
    Community Member
    232 Posts

    Re: Cleaning out the assets folder Link to this post

    Hi
    thanks for the comments, unfortunately these sites are both in ss 2.3 or 2.4 - they're old and big, making upgrade, or managing the files a bit tricky.

    zenmonkey, that's the kind idea I was thinking of, was just wondering someone else had already done the coding!

  • zenmonkey
    Avatar
    Community Member
    524 Posts

    Re: Cleaning out the assets folder Link to this post

    Well I was thinking of throwing something like that together this weekend. I'm moving a clients site from shared hosting (DreamHost) to a Media Temple VS, if I don't have to move the chuff it'll be much better. If I'm successul I'll post my code. My worry is that on shared hosting that many calls may choke hard limits on memory.

  • Futureweb
    Avatar
    Community Member
    232 Posts

    Re: Cleaning out the assets folder Link to this post

    zenmonkey - would be keen to here how you get on!

    Could probably just start by getting the first 100 files or so, and finding any links batch by batch, or else like you say it could overload stuff if there are thousands of files searching through thousands of pages...

    769 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.