I have a requirement to crop the featured image to different sized parts in wordpress.

How to fire an event when the featured image is set(not after publishing) on a new post

I tried using

$(".attachment-post-thumbnail").load(function () {
  alert('I am loaded!');
}).each(function () {
  if (this.complete) $(this).load();

but this is only firing once I publish the post which is good, but I also want it to fire when a user is adding a new post and select a featured image for the post.

The base requirement is

The post should be published along with the featured image and the sliced featured image.

Any wordpress experts here please help

1 Answer 1


I figure it out. This may be a bad solution but atleast it works

 $('.inside').bind('DOMNodeInserted DOMNodeDeleted', function(event) 

Inside a file abhiScript.js (could be any filename :) )


wp_enqueue_script( 'SimpleScript', get_template_directory_uri() . '/assets/js/abiScript.js',array('jquery'));

in function.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.