image_style_url() generates proper links, but sadly it's only a PHP function.
Let's assume I want to substitute file icon with preview image on hover:
(function($) { Drupal.behaviors.ImagePreview = { attach: function (context, settings) { $('.form-managed-file', context).on('hover', function(){ $(this).find('img').attr('src', $(this).find('a').attr('href')); }); } }; })(jQuery); Not the smartest code in the world, but simple, works and illustrates my example. Now, it will show image in the resolution user uploaded. But I need a thumbnail. It's a built in style so I don't need to test if it exists, but I do need valid security token and I need to respect all the Drupal file system settings, just like image_style_url() does. How can I achieve this with jQuery?
Note: In my case both input and output need to happen on jQuery side, as the image may not even be on the server when page is rendered.