简体   繁体   English

如何在MODx Revo主页上添加帖子缩略图?

[英]How to add post thumbnail on home page in MODx Revo?

I'm new to MODx. 我是MODx的新手。 Adding in the post thumbnail creates a visual association for each post or page. 在帖子缩略图中添加会为每个帖子或页面创建视觉关联。 How to add post thumbnail on homepage? 如何在首页上添加帖子缩略图? How to show first image in the post as thumbnail on home page? 如何在首页上以缩略图形式显示帖子中的第一张图片?

As a to WordPress: 作为WordPress:

在此处输入图片说明

If you are trying to use modx as a blogging platform you should look int installing Articles, Archivist & phpthumbof - these packages will provide all the tools & snippets you need to get that done. 如果您尝试将modx用作博客平台,则应注意安装Articles,Archivist和phpthumbof-这些软件包将提供完成该过程所需的所有工具和摘要。 [If not Vasis's solution will be far easier] [如果没有Vasis的解决方案,将容易得多]

Here are two solutions 这是两个解决方案

  1. Create image tv, and manually set image every time when creating a resource. 创建电视图像,并在每次创建资源时手动设置图像。

  2. Create an input filter and apply it to the content field - 创建一个输入过滤器并将其应用于内容字段-

snippet get_first_image : 片段get_first_image

<?php
preg_match('/<img[^<>]+src=[\'"](?P<src>.+)[\'"][^<>]*>/i', $input, $image);
return $image['src'];

and to get image in main page template: 并在主页模板中获取图像:

<img src="[[+content:get_first_image]]">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM