Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically add image names as CSS class to the images #446

Open
srikat opened this issue Aug 4, 2016 · 1 comment
Open

Automatically add image names as CSS class to the images #446

srikat opened this issue Aug 4, 2016 · 1 comment

Comments

@srikat
Copy link

srikat commented Aug 4, 2016

Hello,

Is it possible to automatically add backstretch image names (w/o the file extension) as classes to the images in the generated HTML?

Ex.:

<img style="position: absolute; margin: 0px; padding: 0px; border: none; width: 1920px; height: 1276.8px; max-height: none; max-width: none; z-index: -999999; left: 0px; top: -372.9px;" src="http://example.com/wp-content/uploads/2016/02/minimography_009_orig.jpg">

should be

<img style="position: absolute; margin: 0px; padding: 0px; border: none; width: 1920px; height: 1276.8px; max-height: none; max-width: none; z-index: -999999; left: 0px; top: -372.9px;" src="http://example.com/wp-content/uploads/2016/02/minimography_009_orig.jpg" class="minimography_009_orig">

This would help me in individually adjusting the position of the images for smaller devices using CSS.

I tried using the following jQuery but it works only for the very first image which appears on the page load since the others are not present in the DOM yet.

$('.backstretch img').each(function(i, el) {
    var filename = $(el).prop('src').split('/').pop();
    $(el).addClass(filename);
});

Thanks in advance.

@jamesburgos
Copy link

Thanks for posting this inquiry, Sridhar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants