I have created a blog with rails. All the posts will contain at least one image. On the Blog page, I need to list all the posts. In this list, I need to add the first image of the post infront of each post. How Can I do this? (Please tell me how. Im new to rails!)
If possible, when there are more than one images, I need to select the image which have the css class “features”. If it not there, select the first image. How to do it?
PS : I use CKEditor to write the post and upload images.
I just managed to get the image paths with the regular expression [/img.?src=”(.?)”/i,1]. Know how to identify the css class and use the image with the class “featured” if its available?
I am not sure how CKEditor works with all of this out of the box, but here is what I would do.
Checkout paperclip or carrierwave and create the models/columns that you are looking for.
With both of these you can specify sizes which you could use in your views so you code could look like this: