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

Add option to declare image styles outside the module. #16

Open
ghost opened this issue Jan 21, 2019 · 1 comment
Open

Add option to declare image styles outside the module. #16

ghost opened this issue Jan 21, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@ghost
Copy link

ghost commented Jan 21, 2019

Ideally, components should be able to declare their own style with no need for it to exist in nuxt.config.js. For example:

<template>
  <div>
    <nuxt-img
      :src="testImage"
      :image-style="imageStyle"
      alt="Never forget alt tags!" />
  </div>
</template>

<script>
export default {
  data () {
    return {
      testImage: '/test.png',
      imageStyle: {
        macros: [
          'scaleAndCrop|160|90',
        ],
      },
    }
  }
}
</script>

This would make components much more reusable across projects.

@Barry-Fisher Barry-Fisher added the enhancement New feature or request label Feb 7, 2019
@Barry-Fisher
Copy link
Contributor

Hi @Capu-zennio

Thanks for your feedback on this.

The original use case was to generically create image styles that can be reused rather than specifically having to define image styles in the consuming code, but I understand your point about portability of the components and possibly the flexibility of being able to specify an image style on-the-fly.

Although this shouldn't be too difficult to implement, it does create more of a surface area for testing. Also, the way processed imaged are stored is in a directory which has the same name as the image style key. I think it would be necessary to not only define the image style on the component itself, but also to specify a key that should be used for storing the images in a maintainable way.

I don't have an time to prioritise this right away due to other commitments, but let's keep this open for now. If I get some time then I can pick this up myself. Otherwise contributions are welcome, subject to there being good test coverage.

Thanks,

Barry

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

No branches or pull requests

1 participant