rails 6.1.4 ruby 3.1.1
In my app I display images dynamically. I would like to be able to click on these images (individually) and have a window open that allows me to share these images to a Facebook account.
I don't want a facebook button to appear, I just want to click on an image to share it.
I found this code, which pops up a window, but is not working to share an image:
<% badges.each do |b| %>
<%= image_tag(b,onclick: "fbs_click(this)") %>
<% end %>
<script>
function fbs_click(TheImg) {
u=TheImg.src;
// t=document.title;
alt="LMT-Badge";
window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(alt),'sharer','toolbar=0,status=0,width=626,height=436');return false;
}
</script>
When I click on an image, I get a pop-up window for Facebook, but it has an error message:
f:error ! Sorry, this feature isn't available right now: An error occurred while processing this request. Please try again later.
Any suggestions are appreciated.