Advertisement
VladyCu

Untitled

Nov 1st, 2020
2,437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.84 KB | None | 0 0
  1. <div class="cover-image"> <!-- vlad -->
  2.                                         <?php if ( has_post_thumbnail() ) {
  3.                                         the_post_thumbnail();
  4.                                         }?>
  5.                                     </div>
  6.                                     <script type='text/javascript'>
  7.                                         var image = jQuery(".attachment-post-thumbnail").get(-1);
  8.                                         jQuery(image).hide();
  9.                                         jQuery(image).load(function() {
  10.                                             smartcrop.crop(image, {width: parseInt(image.getAttribute("width")), height: '800'}).then(function(result){
  11.                                                 var ratio = result.topCrop.y/image.naturalHeight*100;
  12.                                                 image.style.objectPosition = "50% " + ratio + "%";
  13.                                                 console.log(ratio);
  14.                                                 jQuery(image).fadeIn();
  15.                                             });
  16.                                         });
  17.                                         jQuery('.cover-image').height(jQuery(window).height() * 0.65);
  18.                                         jQuery(image).closest('.cover-image').append(jQuery(image));
  19.                                     </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement