Skip to content

Commit

Permalink
Added alt attribute to img tags in docs.
Browse files Browse the repository at this point in the history
This is a good practice for accessibility.
Thanks Jessica McKellar for the report.
  • Loading branch information
aaugustin committed Jun 6, 2012
1 parent 17824e2 commit 29a8035
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
8 changes: 4 additions & 4 deletions docs/howto/static-files.txt
Expand Up @@ -68,7 +68,7 @@ Basic usage

.. code-block:: html+django

<img src="{{ STATIC_URL }}images/hi.jpg" />
<img src="{{ STATIC_URL }}images/hi.jpg" alt="Hi!" />

See :ref:`staticfiles-in-templates` for more details, **including** an
alternate method using a template tag.
Expand Down Expand Up @@ -131,7 +131,7 @@ You could, of course, simply hardcode the path to you assets in the templates:

.. code-block:: html

<img src="http://static.example.com/static/myimage.jpg" />
<img src="http://static.example.com/static/myimage.jpg" alt="Sample image" />

Of course, there are some serious problems with this: it doesn't work well in
development, and it makes it *very* hard to change where you've deployed your
Expand Down Expand Up @@ -167,7 +167,7 @@ Once that's done, you can refer to :setting:`STATIC_URL` in your templates:

.. code-block:: html+django

<img src="{{ STATIC_URL }}images/hi.jpg" />
<img src="{{ STATIC_URL }}images/hi.jpg" alt="Hi!" />

If ``{{ STATIC_URL }}`` isn't working in your template, you're probably not
using :class:`~django.template.RequestContext` when rendering the template.
Expand All @@ -193,7 +193,7 @@ tag. It builds the URL for the given relative path by using the configured
.. code-block:: html+django

{% load staticfiles %}
<img src="{% static "images/hi.jpg" %}" />
<img src="{% static "images/hi.jpg" %}" alt="Hi!"/>

It is also able to consume standard context variables, e.g. assuming a
``user_stylesheet`` variable is passed to the template:
Expand Down
2 changes: 1 addition & 1 deletion docs/intro/overview.txt
Expand Up @@ -279,7 +279,7 @@ Here's what the "base.html" template might look like:
<title>{% block title %}{% endblock %}</title>
</head>
<body>
<img src="sitelogo.gif" alt="Logo" />
<img src="sitelogo.png" alt="Logo" />
{% block content %}{% endblock %}
</body>
</html>
Expand Down
4 changes: 2 additions & 2 deletions docs/ref/contrib/staticfiles.txt
Expand Up @@ -380,10 +380,10 @@ full URL for the given relative path, e.g.:
.. code-block:: html+django

{% load static from staticfiles %}
<img src="{% static "css/base.css" %}" />
<img src="{% static "images/hi.jpg" %}" alt="Hi!" />

The previous example is equal to calling the ``url`` method of an instance of
:setting:`STATICFILES_STORAGE` with ``"css/base.css"``. This is especially
:setting:`STATICFILES_STORAGE` with ``"images/hi.jpg"``. This is especially
useful when using a non-local storage backend to deploy files as documented
in :ref:`staticfiles-from-cdn`.

Expand Down
6 changes: 3 additions & 3 deletions docs/ref/models/fields.txt
Expand Up @@ -683,7 +683,7 @@ directory on the filesystem. Has three special arguments, of which the first is
Optional. A regular expression, as a string, that :class:`FilePathField`
will use to filter filenames. Note that the regex will be applied to the
base filename, not the full path. Example: ``"foo.*\.txt$"``, which will
match a file called ``foo23.txt`` but not ``bar.txt`` or ``foo23.gif``.
match a file called ``foo23.txt`` but not ``bar.txt`` or ``foo23.png``.

.. attribute:: FilePathField.recursive

Expand Down Expand Up @@ -714,9 +714,9 @@ base filename, not the full path. So, this example::

FilePathField(path="/home/images", match="foo.*", recursive=True)

...will match ``/home/images/foo.gif`` but not ``/home/images/foo/bar.gif``
...will match ``/home/images/foo.png`` but not ``/home/images/foo/bar.png``
because the :attr:`~FilePathField.match` applies to the base filename
(``foo.gif`` and ``bar.gif``).
(``foo.png`` and ``bar.png``).

By default, :class:`FilePathField` instances are
created as ``varchar(100)`` columns in your database. As with other fields, you
Expand Down
13 changes: 7 additions & 6 deletions docs/ref/templates/builtins.txt
Expand Up @@ -1069,7 +1069,8 @@ value to a maximum value, and then applies that ratio to a constant.

For example::

<img src="bar.gif" height="10" width="{% widthratio this_value max_value 100 %}" />
<img src="bar.png" alt="Bar"
height="10" width="{% widthratio this_value max_value 100 %}" />

Above, if ``this_value`` is 175 and ``max_value`` is 200, the image in the
above example will be 88 pixels wide (because 175/200 = .875; .875 * 100 = 87.5
Expand Down Expand Up @@ -2361,7 +2362,7 @@ using :class:`~django.template.RequestContext` or not.
.. code-block:: html+django

{% load static %}
<img src="{% static "images/hi.jpg" %}" />
<img src="{% static "images/hi.jpg" %}" alt="Hi!" />

It is also able to consume standard context variables, e.g. assuming a
``user_stylesheet`` variable is passed to the template:
Expand All @@ -2380,7 +2381,7 @@ It is also able to consume standard context variables, e.g. assuming a
:ref:`using a cloud service to serve static files<staticfiles-from-cdn>`::

{% load static from staticfiles %}
<img src="{% static "images/hi.jpg" %}" />
<img src="{% static "images/hi.jpg" %}" alt="Hi!" />

.. templatetag:: get_static_prefix

Expand All @@ -2395,16 +2396,16 @@ into the template, you can use the :ttag:`get_static_prefix` template tag
instead::

{% load static %}
<img src="{% get_static_prefix %}images/hi.jpg" />
<img src="{% get_static_prefix %}images/hi.jpg" alt="Hi!" />

There's also a second form you can use to avoid extra processing if you need
the value multiple times::

{% load static %}
{% get_static_prefix as STATIC_PREFIX %}

<img src="{{ STATIC_PREFIX }}images/hi.jpg" />
<img src="{{ STATIC_PREFIX }}images/hi2.jpg" />
<img src="{{ STATIC_PREFIX }}images/hi.jpg" alt="Hi!" />
<img src="{{ STATIC_PREFIX }}images/hi2.jpg" alt="Hello!" />

.. templatetag:: get_media_prefix

Expand Down

0 comments on commit 29a8035

Please sign in to comment.