D
D
Dmitry Sergeevich2015-10-28 19:04:25
Pug
Dmitry Sergeevich, 2015-10-28 19:04:25

Is there a Gulp plugin for auto setting tag properties?

Hello everyone, I ran into the task of setting the properties of tags. There are Jade templates that don't specify ALT TITLE WIDTH HEIGHT. You need to somehow register them there by substituting the plugin into the JADE compilation script, because there are a lot of files! And somehow you need to calculate the WIDTH HEIGHT from the pictures, I also have no idea how to do it.
Has anyone seen a plugin with such a principle of operation? npm search turned up nothing, thanks everyone

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jlekapb, 2015-10-28
@jlekapb

How are you currently storing altand title?
We can write a simple mixin, to specify these properties in a pattern, then go through the files and replace everything imgwith our mixin.

mixin img(src, alt, title)
  - var src = src || 'default-pic.png'
  - var alt = alt || 'default';
  - var title = title || '';

  img(src=src alt=alt title=title)

C widthdid heightnot work, but in theory, you can refer to fs.
Here is what I googled:
https://github.com/netroy/image-size

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question