Of course. This is a very common question for users of the DedeCMS (织梦CMS) system.

Let's break down what cfg_ddimg_width is, how to find it, and how to use it.
What is cfg_ddimg_width?
In simple terms, cfg_ddimg_width is a global configuration variable in DedeCMS that defines the default width for thumbnails (缩略图).
This setting is primarily used by the DedeCMS built-in image processing functions, especially the ones used in the content editor (like the "remote saving image" feature) and when generating thumbnails automatically.
Its main purpose is to:

- Standardize the size of thumbnails across your website, ensuring a consistent look.
- Automatically resize images to fit this width when they are uploaded or fetched from remote sources, preventing oversized images from breaking your layout.
Where to Find and Modify cfg_ddimg_width
You cannot and should not edit this value directly in the database or PHP files. The correct way to manage it is through the DedeCMS后台 (Backend/Admin Panel).
Follow these steps:
- Log in to your DedeCMS Backend.
- Navigate to the 系统 (System) menu in the top navigation bar.
- From the dropdown, select 系统基本参数 (System Basic Settings).
- On the next page, you will see several tabs. Click on the 核心设置 (Core Settings) tab.
- Scroll down the page until you find the option named:
图片默认宽度 (Default Image Width) - The input field next to it is where you can set or change the value for
cfg_ddimg_width. - Enter your desired pixel value (e.g.,
250for 250 pixels). - Scroll to the bottom of the page and click the 保存 (Save) button.
How to Use cfg_ddimg_width in Templates
While the setting is managed in the backend, you can call this variable directly in your DedeCMS template (.htm) files.
The most common use case is to display an article's thumbnail (litpic) and ensure it doesn't exceed a certain width, which can be controlled by this global setting.

Method 1: Using the Global Variable Directly
You can output the value of cfg_ddimg_width directly in your HTML. This is useful if you want to set a max-width style dynamically.
{dede:global.cfg_ddimg_width runphp='yes'}
@me = is_numeric(@me) ? @me : '250'; // Default to 250 if not set
@me = intval(@me);
{/dede:global.cfg_ddimg_width}
However, a simpler and more common approach is to just use it within a DedeCMS tag.
Method 2: The Practical Use Case with {dede:arclist}
The best practice is to use the width and height parameters within the {dede:arclist} or {dede:list} tags. When you specify a width, DedeCMS will automatically use the cfg_ddimg_width (and cfg_ddimg_height) as a reference or fallback.
Example: Displaying a list of articles with thumbnails
In your arclist.htm template file, you would use the following code:
<ul class="article-list">
{dede:arclist row='10' titlelen='30'}
<li>
<!--
Here we use the width and height parameters.
DedeCMS will resize the image to fit these dimensions.
If you only specify 'width', it will maintain the aspect ratio.
-->
<a href="[field:arcurl/]">
<img src="[field:litpic/]" alt="[field:title/]" width="200" />
</a>
<h2><a href="[field:arcurl/]">[field:title/]</a></h2>
<p>[field:description function='cn_substr(@me, 100)'/]...</p>
</li>
{/dede:arclist}
</ul>
In this example, by setting width="200" on the <img> tag, you are telling DedeCMS to make sure the thumbnail is no wider than 200 pixels. The system will respect this more than the global cfg_ddimg_width setting for this specific instance.
Method 3: Using the ddimg function
There is a specific function called ddimg that is designed to work with this configuration. It's often used within content or in more complex loops.
Syntax:
[field:litpic function='ddimg(@me, $width, $height)']
Example:
Let's say your cfg_ddimg_width is set to 250. You can use the function like this:
{dede:arclist}
<img src="[field:litpic function='ddimg(@me, 150, 100)']" alt="[field:title/]" />
{/dede:arclist}
This will force the image to be 150px wide and 100px high, cropping it if necessary. The cfg_ddimg_width acts as a default if you don't specify a width in the function call.
Summary and Best Practices
| Action | Method | When to Use |
|---|---|---|
| Setting the Default | 后台 (Backend) > 系统 (System) > 系统基本参数 (System Basic Settings) > 核心设置 (Core Settings) > 图片默认宽度 |
Use this to set a site-wide default for all automatic thumbnail generation. This is the recommended starting point. |
| Using in Templates | <img src="[field:litpic/]" width="200" /> |
Most common method. Use this when you need to display a thumbnail of a specific size on a page (e.g., homepage, category page). It overrides the global setting for that instance. |
| Advanced Resizing | [field:litpic function='ddimg(@me, 150, 100)'] |
Use this when you need more control, like forcing a specific aspect ratio and cropping the image. |
Key Takeaway:
cfg_ddimg_width is your global default. However, for precise control in your website's design, it's almost always better to specify the width (and optionally height) directly in your <img> tags within your templates. This gives you flexibility for different parts of your site (e.g., larger thumbnails on the homepage, smaller ones in a sidebar).
