What's the recommended way to add content with images and text? - ruby-on-rails-3

What's the recommended way to add content to my rails app ? pages with cloud hosted images like amazon s3& formatted text ?
What I want is just to create a tutorial pages that are easily linked with an index page.
Is there a recommended approach rather than re-inventing the wheel ? what's the popular gems out there ?

If you need fixed content you have just to create an html in the public folder with the html that you need, and link directly from your index view to them.
In order to store the images in the cloud, just upload them and put a reference link to your page fixed content to it.
Otherwise, if you are building a dynamic page that you may upload new images and etc...
Use the paperclip gem. It is a good way to not reinvent the wheel!

Related

How can I lazy-load images with Cloudinary and Strapi?

I am working on a project using Gatsby, Strapi and Cloudinary. I am deploying the frontend on Netlify and the Strapi app on Heroku (with the addition of a Postgresql database instance).
I have been searching for weeks now and but I cannot seem to find a way to lazy-load images sourced through Cloudinary.
I have replaced the default rich content editor on Strapi with the ckeditor so editors can add photos to their content. These are automatically uploaded and served by Cloudinary.
My question is, is there a way to lazy-load the images, and if so, should this be done when serving them from Cloudinary, should I do this as a Strapi middleware or simply through Gatsby?
Note: I am not sourcing the images anywhere on the front-end since it's parsed as html from Strapi. All I'm currently doing in passing the fetched content to a div using
dangerouslySetInnerHtml.
With dangerouslySetInnerHtml directive you are inserting whatever is inside your rich text as HTML content so you lose control of customizing the behavior of that content. Hence, it will be rendered all at once.
There's no built-in way of doing this except by parsing your rich text with a third-party dependency (which I haven't been able to find)/custom method that will give you the capability of wrapping your images with any custom component. The idea, either way, is to parse your rich text blocks to customize the output.
In addition, check if the images tag (<img>) comes with the loading=lazy property attached:
<img src="image.jpg" alt="..." loading="lazy">

Jquery add loading=lazy to all images

I have a bigger webpage and it would take days to add the loading=lazy attribute to all img tags on my site. Is it useful to use something like $('img'). attr('loading', 'lazy') (does this work?) to the site, or will it just make the site more slower?
It doesn‘t necessarly have the expected effect - if you‘re adding the attributes via JavaScript, the page itself has already been parsed by the browser and their preloading scripts as well and all of those images would be been put to the download queue, as if the attribute wouldn‘t have existed on them.
So I would heavily recommend to add those attributes within the source code itself already.

Using Template With DOMPDF

I am using DOMPDF to create a pdf out of my html page. I need to use a specific template for the pdf to be rendered on.
is there a way with DOMPDF to use a pdf template for dynamically creating an invoice?
What is the best way to handle this? Would I need to create the template with html and css?
If it's worth mentioning, I am using Zend2 and installed DOMPDF with composer
I will recommended to use zend\pdf instead of DOMPDF. First it will bit tough but later on you can get high level performance, even able to create 100 pages at one time.
Invoice generation using Zend Pdf
For your requirement dompdf is not a bad choice but
Noway you can put your template other than using HTML and CSS

Any experience with adding Fotorama to a Sitefinity site?

I am working on a project which includes a content slider (images, videos, captions) and we use Sitefinity 5.1. I've been playing with Fotorama and now want to add my content to the site. Has anyone here done that and can give me some guidance?
This is what you could do:
Create a Dynamic Module with fields: Title (Short Text), Description (Long Text), Image (Media Picker). If you need other video's than the builtin Sitefinity video's, use another text field for storing the url to that video.
Add some content :)
Create or change the template that the Module Builder created for you so that the Fotorama Javascript and CSS files are loaded correctly. Make sure the markup of the generated template matches the basics of the Fotorama requirements.
Hope this helps you to get started?
Daniel.

How to tell image search which image matters?

Google image search seems to do a poor job on a site I run in identifying which image on a page should be indexed. In addition it doesn't seem to link that image with lots of the associated data.
Are there any ways of focusing attention for spiders on particular images and associated data, do they need to be within the same tags, or adjacent on the page?
A few tips:
Use a descriptive name, i.e. "tabby-cat.jpg" instead of "img02396.jpg".
Use alt tags on images.
Use descriptive text on the page and around the image.
Make sure the images are in the generated source, i.e. if you click "View source" in your browser, you see <img> tags.
It's also useful to validate your site at http://validator.w3.org in case there are major errors like missing brackets etc that could prevent a spider from parsing the page. (Note: I wouldn't worry about making everything 100% valid since Google is fine with invalid code)
Images in CSS (i.e. backgrounds) are not indexed AFAIK. However I'd suggest using CSS backgrounds for "design" images (a subtle way of getting Google to ignore site headers, custom borders, shadows, etc).
Nor are any images generated from Javascript.
Make sure you're not blocking images through robots.txt. I know that Joomla does this by default.
Sign up at Google Webmaster Tools, add your site, then allow it to be used in Google's "Image Labeller" game which should help tag images.
All images on a page should be indexed. If they aren't then improve your alt tags and possibly rename the image file. There really isn't anything more you can do since search-engines do not read any other context for the image itself except size. If google thinks the image is a duplicate it won't index it either.
Of course if images really do inherit context from the surrounding page then you could just use less images or move them into CSS.
I think Search robot can not read images as we do, so the simple and must thing you should do to your images is using descriptive names, so that spider could know what this image all about. Second one is using ALT tags on images, put in keywords relating to the images.
Those thing are what I do.