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

data-src #367

Open
1dolinski opened this issue Nov 3, 2019 · 1 comment
Open

data-src #367

1dolinski opened this issue Nov 3, 2019 · 1 comment
Assignees
Labels

Comments

@1dolinski
Copy link

1dolinski commented Nov 3, 2019

Love the gem, thanks!

Using the helper method, my images are rendering src instead of data-src. Is there a way the src attribute be data-src?

Example returns

<%= cl_image_tag(item.photo.key, crop: "fill", flags: "lossy", fetch_format: "auto", width: 640, quality: "auto", client_hits: "true", sizes: "100vw") %>

// alt image url

<img width="640" client_hits="true" sizes="100vw" src="https://res.cloudinary.com/happen/image/upload/c_fill,f_auto,fl_lossy,q_auto,w_640/y1f2pEMCynFryYk3644tNE6z">
@eyalktCloudinary
Copy link

@1dolinski Hey!
Looks like you're trying to achieve responsive layout using client-hints. You should know that currently, the client-hints solution is supported only for mobile Chrome. More information can be found here and here.
The recommended approach would be to use our JS responsive solution, which is easy to implement using our SDKs. This way the data-src will be set as you desire.
For example,
cl_image_tag("sample", :width => :auto, :crop => :scale, :responsive => :true)
will create the following img tag -

<img  class='cld-responsive' 
      data-src='http://res.cloudinary.com/eyalkatzt/image/upload/c_scale,w_auto/sample'/>

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

No branches or pull requests

2 participants