Giter VIP home page Giter VIP logo

Comments (8)

toy avatar toy commented on May 29, 2024

Please look at #31 by @bencrouse it allows to set options for image_optim in rails app config, it is already merged, but not yet released.

from image_optim.

bobbus avatar bobbus commented on May 29, 2024

@toy , Thanks for your answer but actually #31 make it possible to config ImageOptim for Rails assets pipeline only, it is not used in other context.

The need of writing a yaml file for the config make it hardly feasible to share a config between several application or when developing a gem.

from image_optim.

bencrouse avatar bencrouse commented on May 29, 2024

You could write your own config/image_optim.yml and do something like this to load it:

IMAGE_OPTIM_CONFIG = YAML.load_file(Rails.root.join('config', 'image_optim.yml')[Rails.env]
config.assets.image_optim = IMAGE_OPTIM_CONFIG

and then where ever else you wanted to use image_optim...

io = ImageOptim.new(IMAGE_OPTIM_CONFIG)

from image_optim.

bobbus avatar bobbus commented on May 29, 2024

@bencrouse , thanks for your suggestion, I will use it from now.

I would still be in favor of adding this directly in this gem in order to avoid having to specify default option everywhere we use ImageOptim.new but not a big deal neither, please close if you feel like it's not wanted for now.

from image_optim.

bencrouse avatar bencrouse commented on May 29, 2024

I think ideally, I'd like to see a ImageOptim.defaults config option where you could 1) find out the out of the box defaults 2) change them for all instances of ImageOptim.

ImageOptim#initialize would then be responsible for merging whatever options are sent into that instance with whatever is in ImageOptim.defaults.

I may take a stab at it if @toy likes the idea and I have some free dev time this week.

from image_optim.

bobbus avatar bobbus commented on May 29, 2024

@bencrouse , seems like a perfect answer to my needs.

from image_optim.

toy avatar toy commented on May 29, 2024

@bencrouse @bobbus Better to put it into ImageOptim::Config.
defaults sounds like it should be overridable by global and local configs. It is a good thing that it will be possible to read defaults, but it will not be possible to override global/local config. Ideas?

from image_optim.

jacek213 avatar jacek213 commented on May 29, 2024

+1 for rails initializer idea

from image_optim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.