How to make the following possible... Some content types have image or file fields. How can I delete those images/ files if I delete the content? So no images and files are left behind. Is this possible out of the box? If no - what would be necessary to make this work? TIA.
thank you for the hint. I always use "1 Folder / Content -> Yes" but there is an other problem. For example on image upload, when i delete one image via checkbox (not the whole content, just one specific), all thumbnails are deleted except "image". So the thumbnail folders are empty, but not the content image folder.
At first to clarify, there is no solution actually such as in Joomla. When you delete a Joomla article with some pictures in it, theses pictures are not deleted. And it's good like this!
To imagine to delete an image included into a content when this content is deleted itself require to have a strong relation between the content and the image and to be sure that no other content are using this image.
There is not many case when the relation exist. It's the case when the SEBLOD image upload field save an image in a specific directory related to the content. In this particular case, we can think to add an option to delete the image too because the file of this image is only used for this content (because the file of the image is stored into a specific directory related to this content).
Another case it's when we're speaking about DAM. In few time you will be able to have a look on a DAM system build only with SEBLOD.
We know it's going to be difficult, but it's important. For 2 months I already have about 1000 ads on my site with up to 4 images each and up to 1 file attachment each. Just imagine in 1 or 2 years what will happen if I cannot delete the assets of the deleted ads.
You've done the hard job making such an extension as SEBLOD, please make some more effort.
I think SEBLOD is already standing out from the rest, but the possibility to delete the content together with the associated assets would make it even much, much stronger.
I've past my abilities to learn PHP, I'm too old for that. If you don't want money say what you need? Do you want me to search for some similar code so it can be easier for you to implement it?
Please take the time and make available some solution, even if we can delete the assets only after we select the option: 1 directory/folder for the assets (images/files) per content/article.
Some thoughts after your input, the written whishes, etc. (just thoughts!) ;-)
Every image should become a piece of content of a IMG content-type-item. Those content type items should be linked exclusively or non-exclusive to other content items. This might be done through describing the relation with a checkbox. Exclusive (part of the linked content-item), non-exclusive. In the first case the image will be deleted too if the content item is deleted.
This way there's always a relation between the image and some 'meta data' in de database (inclusive a unique ID for the image).
Storage of images
Only if we want to keep the original name of an image file, or store it in a 'natural' hierarchic way: Images should be stored for each Content Type in its own media folder, but each content Item should also have its own folder.
For example a content type 'house' (Real Estate) or 'car' (Occasion car sales) - these items will have more then one image or PDF brochure. So, (optional) this could be the structure: images/cck/[cck-type]/[content-id]/
For ex. the media-folder-name for a 'house' with ID 2349: images/cck/house/2349/ That folder (2349) will contain all the media for this house and whenever the house can be deleted, there's a relation.
If besides database-entries also assets (images, video's, etc.) can become part of a Content Item, and only of that item, might indeed take a CCK to a next level. It's upgrading the definition of Content. Or am I too enthusiastic here about features that already exist? ;-)
Another thought... I think that this should be standard behaviour for assets which are part of a Content Item. Think about it... it makes the most sense. Make the asset just as much part of the content as the title and description. On the other hand... it might be configurable by an option 'relation'.
1) asset has a link with 1, and only 1 content item (default)
2) asset has a link with 0, 1 or more content items.
Again… just some thoughts.
How does this work in Drupal? Anyone? It's fair to say that Drupal has quite some history and experience with their CCK / Views. We can learn from it how to (not) do it, improve etc. Perhaps another time some research. My post is way toooo long already ;-)
The problem unfortunately remains if the user deletes the articles himself. I'm thinking how to make the content to get to trashed state instead of being deleted permanently with the Free text delete plugin.
My problem was that after few months client deleted articles but not completly trashed them (articles still persist in database). Real problem was how to delete about 1GB unused related files (hundreds of pdf, images) from server. All cleaning job finished in one click.
In com_deleter principle to delete files related to trashed articles is:
1. all articles with status trashed still persist in database and have status -2 2. when you go to component Deleter you will see table list of all trashed articles 3. att the bottom when you press "Delete all" it will delete all files related to trashed articles 4. after that you can go back to Article manager (status "trashed") and finish job (delete trashed/empty trash)
What is important to understand is relation, in my case I have 1 Folder/Content and 1 Folder/User set to "Yes", and because of that I have folder structure : images/user-id/aricle-id - and in different case this variant of com_deleter will not work!
But - this script is very simple and I belive that is very easy to adjust it to do same job for different cases (set your custom sql query and do small adjusts in php part). Also this component is very easy to rebuild it for J3, add security checks etc.
p.s. eg. if you want to delete files related to articles what are not persist in datatable I'll do this:
1. find relation between content and folder - that's will give you your custom folder structure 2. do sql query to find related folders (related to article ID) 3. check/compare folder tree/listings with php to find unrelated folders/files 4. delete unrelated folders/files