11 years ago
21
Topic

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.

Get a VIP membership
310 Posts
ricco
11 years ago
0
Level 1

Yes, I'd like to know the answer of this too.

It is very important issue specially for bigger projects.

Thank you

84 Posts
Skepsis
11 years ago
0
Level 1

Hello,

I´m also very interested in a solution for this problem.

Greetings
Skepsis

11 years ago
0
Level 1

Same here... A plugin would be very useful!

11 years ago
0
Level 1

Hi everybody and thanks.

A solution can be to add an option in the upload field only when the option "1 Folder / Content" is on Yes. Because in this case only there is a link between the image and the content.

Please add a feature request in the tracker.

Regards

151 Posts
pixelpixel
11 years ago
0
Level 1

Hi Sebastien,


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.


kind regards

310 Posts
ricco
11 years ago
2
Level 1

Hi friends,

I've added a feature request in the tracker here: http://www.seblod.com/resources/tracker/5223

Meanwhile does anybody have a temporary solution for this issue.

Bes wrote:

A solution can be to add an option in the upload field only when the 
option "1 Folder / Content" is on Yes. Because in this case only there 
is a link between the image and the content.<br>

Bes you are talking about some kind of solution but could you please explain how exactly this can happen.

Thank you and best regards

11 years ago
1
Level 2

Hello,

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.

Regards.

310 Posts
ricco
11 years ago
0
Level 3

Hi Bes,


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.


Thank you
Best regards
Ricco

310 Posts
ricco
11 years ago
0
Level 1

Hi again,


At least is there a way to be notified when a content is deleted?


If we are able to receive an email when a content is deleted, with the id of the deleted content we can delete the assets manually, but I'm wondering how this could happen.


May be someone already knows?


Thank you

All the best

Ricco

11 years ago
0
Level 1

Hi Bes and others, Thx for al your replies and thinking along. Conclusion for now... it can't be done out of the box. Though, the idea / feature whish might be an interesting one. 


Looking forward to see that DAM. (Had to look that up: http://www.contentmanager.eu.com/dam.htm)


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 ;-)

310 Posts
ricco
11 years ago
0
Level 1

Hi,


I think I've found a temporary workaround of the problem it's not great but at least you can manually delete the assets.


Please see my last post in this topic.


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.


Regards

Ricco

310 Posts
ricco
10 years ago
1
Level 1
Hi,

Finally I've found a way to be notified when an article is delete.

It's this plug-in which helped me Content Update Notifications Plugin.

It's not the best solution to the problem but at least now I receive an email with the article id when a user deletes an article and I know which assets to remove manually.

Regards
Ricco
548 Posts
joomleb
10 years ago
0
Level 2
Many Thanks for suggestions.
I think this feature is so a must that really can not understand how could do to survive large projects with Seblod till today without this feature...
10 years ago
0
Level 1
please feel fre to vote for this in tracker :) 
10 years ago
1
Level 1

Hello for all.

I had the same problem on one site (Seblod 2) and solved with custom "one-file" component. 

Principle is very simple, all deleted articles go to trashed status (in database status =-2), also my setup is 1 Folder / Content and

1 Folder / User set to "Yes". In Seblod, in that case, link to files go images/article-created-by-user-id/article-id, and that's it.

Here is "20 minutes" "one-file" component for J25 and Seblod 2 created to solve my problem (delete articles attachments from server) ->LINK

Important note: install it, delete files and after it remove/uninstall because in that component I don't care to much about Joomla standards, but it's work

regards

p.s. inside php file you can set custom query

310 Posts
ricco
10 years ago
0
Level 2

Hi Olsa,

Thank you for your effort.

Is your component Joomla 3.X compatible? Also does it manage the already existing images or just the newly published once?

Best regards,

Ricco

10 years ago
1
Level 1

Hello Ricco.

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.

Regards.

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

310 Posts
ricco
10 years ago
0
Level 2

Grate, thank you.

Have a nice day.

310 Posts
ricco
9 years ago
0
Level 1

Hi,

I've created a campaign for this feature: http://igg.me/at/71ymlS3t5q0/x/9795470


Please contribute.

Thank you

116 Posts
nycxav
6 years ago
0
Level 1

Hi, 

I know it's an old topic but I'm still looking for a solution to this issue. 

Any update?

Thanks in advance. 

4229 Posts
Kadministrator
6 years ago
0
Level 1

Deleting images from artices is now part of the core. Please don't reopen 3 years old posts.

Get a Book for SEBLOD