evanmcd Posted January 5, 2012 Share Posted January 5, 2012 Hi, Just came up against this situation, and am wondering if it's me, or if there's something that can be improved upon: 1. Add images to a page via an image field 2. On another page's tinyMCE editor, select an image from the previous page, resizing them (thus creating a new image) 3. Delete the images from the page in step 1. 4. The images inserted in step 2 are now missing. is this the expected behavior, or have I uncovered a bug? Is there a known way to manage this sort of thing without needing to keep track of what pages use which images? Thanks! Link to comment Share on other sites More sharing options...
ryan Posted January 5, 2012 Share Posted January 5, 2012 This is the correct behavior. Not ideal I know, but that's also why it's best to use this particular feature carefully. The issue here is that TinyMCE saves a bunch of HTML markup, and that markup can feasibly have anything in it (images and links on site or off site). ProcessWire doesn't know anything about the markup that TinyMCE is saving. When you add an image in there, you are essentially adding an <img> tag like in any other HTML document, and the same rules apply. If you pull images from other pages (for TinyMCE), it's best to setup a shared 'gallery' page (or pages) designated for the purpose and you generally assume that all those images are in use until proven otherwise. Even better is to upload images on the page where you are using them (assuming the same image doesn't need to be populated on several pages). Down the road, I do think we'll be able to solve this by making a module that scans textarea fields for recognized paths (when you save a page) and keeps a list of them in a DB table. When you try to delete something, it'll abort if it finds a link to that asset on another page. While I don't like to have PW getting involved in trying to hunt down and manage links in HTML documents, it's probably worth the compromise. On the other hand, pulling images or files from other pages via the API is a safe bet. If an image gets deleted, it no longer shows up in the API call. So it's quite common to pull the first image on a page for showing a thumbnail with a listing (for example) or pull an image randomly from a page that has several. It's only when dealing with TinyMCE that you may not always want to exercise the power that it gives you in pulling images/files from anywhere (unless you've already made a plan for it). Link to comment Share on other sites More sharing options...
apeisa Posted January 5, 2012 Share Posted January 5, 2012 One solution in the long run could be some totally different way to manage text & images content. Maybe something like MadMimi Newsletter has: https://madmimi.com/tour/create_send (video on top right). Link to comment Share on other sites More sharing options...
ryan Posted January 6, 2012 Share Posted January 6, 2012 MadMimi (love the name) looks pretty cool. I enjoyed watching this, thanks for the link! I'm not sure I understand how (or if) it solves the issue of an image being deleted somewhere else. But it's a beautiful example of editing and I like the way they are going about things there. I don't think it is necessarily a substitute for TinyMCE, but it seems perfect for what they are using it for. Rather than a rich text editor, they are using Markdown combined with <a href="http://markitup.jaysalvat.com/home/">MarkItUp</a> (I think), which is a great editing tool and one I'd really like to build an Inputfield for. Link to comment Share on other sites More sharing options...
apeisa Posted January 6, 2012 Share Posted January 6, 2012 Ryan, you are right. I was thinking that when you input content this way, you would save it to the database in more relational manner (not just a bunch of markup, but more metadata about images used, how they are positioned etc). But even if you would do that, it doesn't resolve the problem that whenever image is removed, you need to check all the content fields if that image is used. So similar solution (putting images and fields where they are used to db table) is needed anyways. Link to comment Share on other sites More sharing options...
evanmcd Posted January 6, 2012 Author Share Posted January 6, 2012 OK, thanks for the info guys. It's not a huge issue as I don't think clients will use the ability to display images from other pages, and now knowing that this is the expected functionality (at least for now), we won't reveal that feature to them without explanation of the specifics. Thanks again for your work on this. Looking forward to 2.2! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now