Skip to content
relocate images to fit image box
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
src Bugfix
LICENSE Bump version 1.0.2
README.md Update readme.
bower.json Update bower version.

README.md

relocator.js

relocate images to fit image box.

relocator

Usage

html:

...
<div class="container">
    <div class="box">
        <img src="images/height-image.jpg" alt="">
    </div>
    <div class="box">
        <img src="images/width-image.jpg" alt="">
    </div>
</div>
...
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/relocator.min.js"></script>

relocate all images

<script>
    jQuery(document).ready(function($){
        $('.box img').relocate();
    });
</script>

custom

$(imageSelector).relocate($imageBoxSelector);
  • imageBoxSelector Specify picture reference container, default picture parent reference.

example:

<div class="box">
    <div class="img-wrapper">
        <a href=""><img src="" alt=""></a>
    </div>
    <p>The image title</p>
</div>
...
<script>
    jQuery(document).ready(function($){
        $('.box img').relocate('.img-wrapper');  // Actually:$(img).closet(''.img-wrapper'')
    });
</script>

License

MIT

Something went wrong with that request. Please try again.