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

Passing array of images doesn't render images #19

Open
danchristian opened this issue Mar 19, 2019 · 1 comment
Open

Passing array of images doesn't render images #19

danchristian opened this issue Mar 19, 2019 · 1 comment

Comments

@danchristian
Copy link

I am pulling an array on images from Netlify CMS and passing that to vue-picture-swipe component, but the acutal images don't render, even though the path is correct etc.

Not sure what I am doing wrong?

Template

vue-picture-swipe(:items="items")

Script

    <script>
      export default {
        data: function() {
          return {
                    items: []
                };
        },
    
            created: function () {
                this.imageList()
            },
    
            methods: {
                imageList: function () {
                  const files = require.context('~/content/gallery/images/', false, /\.md$/);
    
                    let images = files.keys().map(key => ({
                        ...files(key)
                    }));
    
                    let items = images.map(function(value) {
                        return {
                            'src': value.attributes.imgSrc,
                            'thumbnail': value.attributes.imgSrc,
                            'alt': value.attributes.imgDesc
                        }
                    });
    
                    return this.items = items
                }
            }
    
        };
    </script>  

Rendered HTML

<img src="/assets/uploads/image.jpg" alt="Test Image description" itemprop="thumbnail">
@beejaz
Copy link

beejaz commented Feb 8, 2020

@danchristian I believe you must add image dimensions to the array, weight (w:) and height (h:)

let items = images.map(function(value) {
return {
'src': value.attributes.imgSrc,
'thumbnail': value.attributes.imgSrc,
'alt': value.attributes.imgDesc,
'w': 600,
'h': 400,
}
});

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