Skip to content

Display first of several images in the grid #961

Answered by adrianthedev
iainbeeston asked this question in Help
Discussion options

You must be logged in to vote

I managed to get it working. You need to make a few changes:

  1. Change the field type to external_image
  2. Change the computed property to the following main_app.url_for(model.images.first). We call url_for with the image, and we need to call it on the main_app because we're executing it inside a Rails engine.
  grid do
    cover :cover_photo, as: :external_image, is_image: true, link_to_resource: true do |model|
      if model.images.first.present?
        main_app.url_for(model.images.first)
      else
        ""
      end
    end
    # title
    # #body
  end

Please let me know if that fixed it 🤙

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@iainbeeston
Comment options

Answer selected by iainbeeston
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants