ps批量把文件名添加到图像_自动为带有文件名的投资组合图像添加字幕
ps批量把文件名添加到图像A more elegant solution to captioning images for galleries and portfolios, and one that requires considerably less work than adding a URL variable, is to create a dependency on an accurat
ps批量把文件名添加到图像
A more elegant solution to captioning images for galleries and portfolios, and one that requires considerably less work than adding a URL variable, is to create a dependency on an accurate, descriptive image filename. In essence, this is a variation on the self-made pages technique I have demonstrated before.
一种为画廊和作品集添加标题图像的更优雅的解决方案是创建对准确,描述性图像文件名的依赖,该解决方案比添加URL变量所需的工作少得多。 本质上,这是我之前展示的自制页面技术的一种变体。
Of course, your gallery images should already have descriptive filenames, with hyphens in place of spaces. Assuming that you have used a GET
variable that contains the image filename (I’m going to call the variable $img
for the purposes of this example), it should not be a stretch to add something like the following:
当然,您的图库图像应该已经具有描述性的文件名,并用连字符代替空格。 假设您使用了一个包含图像文件名的GET
变量(出于本示例的目的,我将调用变量$img
),那么添加如下内容应该不是一件容易的事:
<?php $title = ucwords(sub_str(str_repace("-"," ",$image), 0, -4));
# the sub_str assumes that the file extension is always three characters
?>
And the code for displaying the image would change to:
并且显示图像的代码将更改为:
<img src="assets/images/<?=$image?>" alt="<?=$title?>">
While considerably more efficient that using GET
, this method still has some disadvantages. The primary drawback is that the caption is limited to whatever the image filename is… and because filenames cannot contain commas or other punctuation, nor be longer than 255 characters, neither can the caption.
尽管比使用GET
效率更高,但此方法仍存在一些缺点。 主要缺点是字幕只能使用图片文件名...,并且文件名不能包含逗号或其他标点符号,并且不能超过255个字符,因此字幕也不能。
While rather more complex, a technique that avoids those disadvantages entirely is one that uses metadata from the image itself to create the caption.
虽然比较复杂,但是一种完全避免这些缺点的技术是使用图像本身的元数据创建标题的技术 。
翻译自: https://thenewcode.com/409/Automatic-Captioning-of-Portfolio-Images-with-Filenames
ps批量把文件名添加到图像
更多推荐
所有评论(0)