GHOST CMS - Responsive Images 图片显示

Responsive Images

Optimise the performance of your site by outputting images at different sizes depending on where they appear

Overview

So you upload glorious 2000px feature images to all your posts to appear in the giant hero/header on individual articles and things look great. On your home page, though, you‘re displaying those feature images as 250px thumbnails for every single post. And there are a lot of them. Suddenly, those big beautiful 2000px jpgs are no longer ideal and your site performance slows right down.

Ghost‘s dynamic image sizes feature solves this, by allowing you to use scaled down images or build out responsive image srcsets for your theme.

Configuration

First, in your theme‘s package.json - you‘ll need to set up which sizes you‘d like to use. You can change these sizes at any time and Ghost will automatically regenerate copies of your images at the specified sizes, so treat this more like a cache than anything else. Generally speaking, less is better. Try to not have more than 10 image sizes so your media storage doesn‘t grow out of control.

Here‘s a sample of the image sizes in Ghost‘s default Casper theme.

package.json

"config": {
    "image_sizes": {
        "xxs": {
            "width": 30
        },
        "xs": {
            "width": 100
        },
        "s": {
            "width": 300
        },
        "m": {
            "width": 600
        },
        "l": {
            "width": 1000
        },
        "xl": {
            "width": 2000
        }
    }
}

Using image sizes

Once your image sizes are defined, you can pass a size parameter to the {{img_url}}helper in your theme to output an image at a particular size.

<img src="{{img_url feature_image size="s"}}">

If you want to build out full responsive images, then create your html srcsets passing in multiple image sizes, and let the browser do the rest.

Here‘s an example from Ghost default Casper theme implementation:

index.hbs

<img class="post-image"
    srcset="{{img_url feature_image size="s"}} 300w,
            {{img_url feature_image size="m"}} 600w,
            {{img_url feature_image size="l"}} 1000w,
            {{img_url feature_image size="xl"}} 2000w"
    sizes="(max-width: 1000px) 400px, 700px"
    src="{{img_url feature_image size="m"}}"
    alt="{{title}}"
/>

Compatibility

Ghost image sizes will be automatically generated for all images uploaded directly toGhost, and will regenerated as needed automatically whenever you change an image, a list of sizes, or the theme being used. Unlike other platforms, there‘s no manual work needed to manage image sizes, it‘s all done in the background for you.

Dynamic image sizes are not compatible with externally hosted images. If you insert images from Unsplash or you store your image files on a third party storage adapterthen the image url returned will be determined by the external source.

原文地址:https://www.cnblogs.com/QDuck/p/12081532.html

时间: 2024-11-09 10:16:21

GHOST CMS - Responsive Images 图片显示的相关文章

ROM+VGA 图片显示

内容 1.将一幅图片制成mif文件,初始化rom,图片像素为 120 * 60 2.驱动VGA,将图片显示在屏幕上 1.VGA 时序 下面是我的笔记截图,感觉更好理解. 2.640*480 60hz VGA 为什么要选用 25Mhz 的时钟进行驱动呢? 1s时间内显示60幅图像,每幅图像的像素总数为 800 *525 (640*480是指的有效像素,800*525是包含了所有的,具体情况见下图) 因此完成一幅图像的时间为 1s/60 =16.6ms 完成一行需要 16.6ms / 525 =31

Swift开发教程--如何自定义TabBarItem的图片显示

在做项目的时候,如果使用系统的UITabBarController的时候,底部的tab自定义图片显示是蓝色和灰色的,这不是我们所想要的效果. 如果想显示自定义的按下和弹起的图片效果,这个时候就需要对TabBarItem进行修改. 以下就是具体的示例: var itemNameArray:[String] = ["down_32","add_32","plane_32","circle_32"] var itemNameSele

赵雅智_运用Bitmap和Canvas实现图片显示,缩小,旋转,水印

上一篇已经介绍了Android种Bitmap和Canvas的使用,下面我们来写一个具体实例 http://blog.csdn.net/zhaoyazhi2129/article/details/32136179 运行效果: 主要代码 package com.example.guaguale; import android.app.Activity; import android.content.Context; import android.graphics.Bitmap; import and

Qt添加窗口背景图片、Label图片显示、、Label文字显示

一.添加窗口背景图片 重写MainWindow绘制事件 void MainWindow::paintEvent(QPaintEvent *event) { QPainter painter(this); painter.drawPixmap(0,0,width(),height(),QPixmap("background.png")); qDebug()<<event; }记得在头文件中声明函数. 二.图片显示 QPixmap car("Car.png"

猎豹浏览器关掉图片显示

1.关闭极速模式下的图片显示 选项-->更多设置-->网页内容(内容设置)-->图片(不显示任何图片)       2.关闭兼容模式下的图片显示 工具→Internet选项→高级→设置→多媒体→去掉"显示图片|"前的勾 3.如果向任何情况下都不显示图片则完成前面两种设置. 猎豹浏览器关掉图片显示,布布扣,bubuko.com

在VC6中基于dll开发插件用于各种图片显示(BMP/TGA/JPG/GIF/PNG/TIF/ICO/WMF/EMF/...)

一.图片显示 图片显示的方法: 1.  直接写程序 2.  第3方库 3.  调用COM组件的IPicture接口 4.  使用MFC的CPictureHolder类 5.  使用GDI+的CImage类(VC6无,从VS2003开始有) 测试过的方法有1.3.5. 测试过的格式有BMP/TGA/JPG/GIF/PNG/TIF/ICO/WMF/EMF. IPicture接口不支持的格式有:PNG和TIF. GDI+支持全部格式. 二.插件的实现(VC6) 只做了基于DLL的插件实现试验,基于“公

使用系统UITabbarItem自定义图片显示原本颜色和自定义文字颜色

...... ThirdViewController *thirdVC = [[ThirdViewControlleralloc]initWithTitle:@"搜索信息"]; //设置tabbarItem 的图片显示原图颜色: thirdVC.tabBarItem = [[UITabBarItemalloc]initWithTitle:@"搜索"image:[[UIImageimageNamed:@"login_usernick"] image

4.C#WinForm基础图片(显示和隐藏)

要求: 软件上有一张图片,默认是隐藏的.用户在文本框中输入身份证号(131226198105223452),点击按钮,如果年龄大于18岁,则显示图片. 知识点: 取当前年份,Date Time Now Year所需用到的函数 函数一: string string.Substring(int startIndex,int length)(+1重载)                从此实例检索字符串.子字符串从指定的字符位置开始且具有指定的长度          异常:              

Latex图片显示问题(1)

用latex编译后,若用dvipdf生成pdf文件,则其中有个eps图的左侧会显示不完全:若是用dvips--pspdf生成pdf文件,图像显示没问题. 这种情况的问题出在,加载 graphicx 宏包的时候没有加任何驱动选项,所以在 LaTeX 的时候,默认使用 dvips 这个驱动模式.因此,在 LaTeX - DVIPDFM(x) 工具链的时候图片显示会出问题.也就是必须使用 LaTeX - dvips - ps2pdf 这个工具链才行.