Comments (9)
@courtsimas That's actually what I did and it's indeed super simple.
Just feels a bit awkard to include url_helpers in the model but I guess it's fine, nothing wrong with that.
The better solution is probably to use the ruby client as suggested by @robypez
Hey @ericdeansanchez, maybe I was reading the doc too fast, but I think the part about including the helpers in the model ("...This is useful for things such as including imgix URLs in JSON output from a serializer class...") should have a subtitle above it (with keywords like model, API, or something like that). I was having the impression that I couldn't use this outside of html/erb views.
๐
from imgix-rails.
Hi @robypez apologies for the late response. Could you possibly provide more details as to what you're looking for? It would help me considerably in trying to provide a possible example. Thanks
from imgix-rails.
The documentation has no info on using these helpers or similar methods outside of the context of views. (for instance, in controllers, or in custom presenters). That would be nice to know...
UPDATE: I take that back. It's here: https://github.com/imgix/imgix-rails/blob/master/README.md#ix_image_url
from imgix-rails.
It could be clearer in the docs thought as this will be often used in an API context :)
from imgix-rails.
In the model I'm using Imgix Ruby now
from imgix-rails.
Canโt people just extend the imgix module inside the model and use the helper just like in a view? Thatโs what we do. Takes 2 seconds to do.
from imgix-rails.
Inside a model
ix_image_tag('/unsplash/hotairballoon.jpg', url_params: { w: 300, h: 500, fit: 'crop', crop: 'right'}, tag_options: { alt: 'A hot air balloon on a sunny day'
Method not found. But this works. I need to use ix_img_tag with nokogiri in my content model
include Imgix::Rails::UrlHelper
puts ix_image_url('/users/1/avatar.png', { w: 400, h: 300 })
# => https://assets.imgix.net/users/1/avatar.png?w=400&h=300
from imgix-rails.
Hello ๐ @karimmorta @robypez I'd love to help here. It seems what's being asked here is better or more descriptive documentation related to use inside of models.
My question is, what kind of documentation would help in this situation? Is there a particular feature that seems to be missing or missing documentation? Is there a common task here that could be described and/or documented better?
I'm fairly new here at imgix and I'm just trying to build up a little context.
I appreciate and look forward to you feedback! :)
from imgix-rails.
@karimmorta Great! I am glad you've found a solution.
a subtitle above it (with keywords like model, API, or something like that). I was having the impression that I couldn't use this outside of html/erb views.
I think this could be a great addition; I will collect the context of this conversation into improved documentation + an example.
Canโt people just extend the imgix module inside the model and use the helper just like in a view?
Yes! :)
from imgix-rails.
Related Issues (20)
- Updating imgix-rb dependency to v4? HOT 2
- ssrf external service interaction to malicious external source - security issue HOT 8
- `ix_image_url` doesn't work with fingerprinted assets anymore HOT 3
- Usage with multiple sources? HOT 1
- Multiple secure_url_tokens when using multiple sources HOT 3
- max_width not working HOT 4
- Support Multiple Sources HOT 4
- data-srcset instead of srcset HOT 5
- Switching between dev (local filesystem) and production (aws s3) HOT 2
- SemVer? Changelog? HOT 4
- ix_picture_tag provides wrong ouput of v3 HOT 1
- extra srcset link generated causes issue on non-retina displays HOT 1
- bundler restricted to version <2.0
- ActiveStorage support HOT 5
- Support latest version of imgix-rb HOT 1
- `min_width` and `max_width` are rendered to HTML tag HOT 1
- Digest hash HOT 3
- Getting static image instead of GIF HOT 4
- data attributes instead of plain srcset, src, sizes attribute HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imgix-rails.