I am trying to: Implement a "remove image" from image field.
Yes.. i can just delete the url and click update, that solves the issue. But when we build sites using toolset so that it's updated by the client, you can imagine what they say about this?....
It's just not user-friendly.
Anyway, this is jquery code i created so far. It works perfectly, however this is only the current state after the page is loaded.
hidden link
If i add a picture again the button TESTE (the button that removes the thumb and clears the input) doesn't show because it's not wrapped under an event listener. You can try and press TESTE and then INSERT IMAGE and you will see the issue.
I know this is custom development and it's not "hired" under the license we purchase, but when your stuck because you think things are user-friendly and pretty much basic and they're not, you end up here (sarcasm included).
Is there any easy way to achieve this? I don't want to hack that "insert image" function so that i can update toolset in the future.
This is all in the backoffice, i'm not using Toolset Forms.
Thanks
Hi Pedro,
Thank you for contacting us and I'll be happy to assist.
Your understanding is correct and custom development is beyond the scope of support that we provide. But we do our best to guide in the right direction, whenever possible.
To add a remove link/button next to an image field's preview, you can try a slightly updated script:
jQuery(document).ready(function($){
$(".wpt-field.wpt-image").each(function() {
$(this).append('<a class="image-file-remove button button-secondary" href="#">Remove image</a>');
$(this).children('a.image-file-remove').on("click", function(e){
e.preventDefault();
$(this).parent().children().children().children().children('img').remove();
$(this).parent().children().children().children().children('input.wpt-form-textfield').val('');
});
});
});
For further assistance with custom jQuery script, I'll recommend sharing your question at dedicated jQuery forums, such as:
hidden link
https://stackoverflow.com
I hope this helps!
regards,
Waqar
My issue is resolved now. Thank you!