大型网站中图像的命名约定
这是一个关于在网络项目中组织大量图像的问题。假设您的 Web 项目中有以下两个图标,例如,代表选择的产品或未选择的产品:
你会给它们起什么名字?
似乎是一个简单的问题,但我怀疑命名图像是一门艺术。
例如:
star_active.png 和 star_inactive.png:看起来很公平,但如果您想稍后用圆圈替换星号该怎么办?那么你的名字会产生误导,所以你必须重命名它,然后更新所有的 css 等。
product_selected.png和product_unselected.png:非常适合用于选择特定操作时产品,但如果我想将相同的图像用于不同的目的怎么办?然后名称会令人困惑且过于具体。
图像大小应该是图像名称的一部分吗?例如。 someImage_16.png
您发现的命名图像的最佳命名约定是什么?
This is a question about organising lots of images in a web project. Say you had the following two icons in a web project that represeneted, for example, a product selected or a product not selected:
What would you name them?
Seems a simple question, but I suspect naming images is something of an art.
For example:
star_active.png and star_inactive.png: Seems fair enough but what if you want to replace the star at a later date with a circle say. Then your name is misleading so you would have to rename it and then update all your css etc.
product_selected.png and product_unselected.png: Great for the when used for the specific action of selecting a product but what if I wanted to use the same image for a different purpose. Then the name is confusing and too specific.
Should the image size be part of the image name? eg. someImage_16.png
What is the best naming convention you have found for naming images?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要一种命名约定来预测文件的未来属性和应用程序,以便您永远不必更新文件名。那是不可能的。最初命名文件时,您必须依靠自己的直觉。
没有办法解决这个问题。如果您最终对文件或其应用程序进行了大幅更改,以至于文件名不再准确反映其用途,那么您将需要保留误导性名称或在整个文件中替换它。
大多数像样的文本编辑器应该能够轻松地在多个文件中完成后者。
唯一的选择是指定从一开始就没有描述性的名称,这显然不是一个好主意。
听一下Kobi并研究一下精灵,或者如果你不喜欢精灵,就按照Arvin所说的方式去做,给出的原因。
You're asking for a naming convention that predicts future attributes and applications of the file so that you never have to update the file name. That is impossible. You have to rely on your own intuition when you initially name the files.
There is no way around it. If you end up changing either a file or it's application so drastically that the file name no longer accurately reflects its use, then you will either need to keep the misleading name or replace it throughout your files.
Most decent text editors should be able to easily do the latter across multiple files.
The only alternative is to assign names which are not descriptive from the start, which is obviously not a good idea.
Listen to Kobi and look into sprites, or if you're averse to sprites, do it the way Arvin said for the reasons given.