Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Last image is still shown in FrontEnd after deletion #46

Closed
Inza opened this issue Jan 3, 2012 · 7 comments
Closed

Last image is still shown in FrontEnd after deletion #46

Inza opened this issue Jan 3, 2012 · 7 comments

Comments

@Inza
Copy link

Inza commented Jan 3, 2012

I encountered an issue in the page-images engine.

When I add some images to a page (even only one) and then I deleted it from the administration, it is still shown in the front end.

Maybe I use bad method for showing images in the front end, or there is a bug? Not sure.

I use the following code for showing images in the front end:

<% if @page.images.length>0 %>
    <% @page.images.each do | el | %>
        <img src="<%=  el.thumbnail("772x550").url %>" alt="" />
    <% end %>
<% end %>

Do you have any idea what am I doing wrong? Or can you confirm that there really is some issue? Thx!

I use:

  • ruby 1.9.2p290 (2011-07-09 revision 32553
  • rails (3.0.11)
  • refinerycms (1.0.9)
  • refinerycms-images (1.0.9)
  • refinerycms-page-images (1.0.4 b304279)
@parndt
Copy link
Member

parndt commented Feb 27, 2013

I'm not sure.. are you sure you saved the page? Year old issue so maybe you fixed it already..

@rrouse
Copy link

rrouse commented Sep 9, 2013

This does still happen.

If you have only one image on the page, trying to delete it doesn't work. The javascript removes it from the view, but saving the page does not delete the image from the page. If you edit the page again, the image is back.

@jbourassa
Copy link
Contributor

Yeah just stumbled on this issue. It's not a super easy one because of the way the plugin is architectured. Since there are no inputs left, the form does not submit anything for images, therefore no images are getting deleted. We want to submit an empty array through POST, but I'm not sure you can do this with Rails / Rack. Another option would be to change the plugin and use _destroy attribute rather than fancy deleting logic, but that's basically changing the HTTP API and could be backward incompatible.

I'll look into it tomorrow, but it's most likely not going to be pretty. If anyone sees an easy fix, I'd be glad to hear.

@parndt
Copy link
Member

parndt commented Oct 8, 2013

I think that using _destroy would be the best, personally.. if that's possible.

jbourassa pushed a commit to hooktstudios/refinerycms-page-images that referenced this issue Oct 9, 2013
@jbourassa
Copy link
Contributor

@parndt It of course would be better. Honestly, this plugin is really hard to maintain and breaks a lot of conventions all over the place.

I tried to quickly implement a fix using _destroy, but that basically means changing pretty much all the logic in the backend, the frontend, and how the images are associated. I decided to add a little patch on the pile rather than rewriting the plugin from the ground up. Sorry about that.

@parndt
Copy link
Member

parndt commented Oct 9, 2013

@jbourassa seems like it works though, care to open a pull request?

jbourassa pushed a commit to hooktstudios/refinerycms-page-images that referenced this issue Oct 10, 2013
Hotfix rather than changing the plugin behaviour to use `_destroy`
because that would mean reimplement the whole thing.
@jbourassa
Copy link
Contributor

The first one is a mistake =( I tried something but it didn't quite turn out as I expected.

@parndt parndt closed this as completed in abe8b57 Oct 13, 2013
parndt added a commit that referenced this issue Oct 13, 2013
Fix bug preventing deleting the last image. Fixes #46
kaerus pushed a commit to kaerus/refinerycms-page-images that referenced this issue Jan 24, 2014
Hotfix rather than changing the plugin behaviour to use `_destroy`
because that would mean reimplement the whole plugin.
ugisozols pushed a commit that referenced this issue Jan 25, 2014
Hotfix rather than changing the plugin behaviour to use `_destroy`
because that would mean reimplement the whole plugin.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants