Static images now use flask url_for to get url

This commit is contained in:
Andrew Bryant 2023-09-11 10:28:24 -04:00
parent 9610d995de
commit b6f7f7a2b7
6 changed files with 41 additions and 38 deletions

View File

@ -1,4 +1,4 @@
title = 'Frequently asked question'
title = 'Frequently asked questions'
content = {
'How does this process work?': {

View File

@ -1,12 +1,14 @@
from flask import url_for
title = 'About me'
content = {
'section 1': {
'images': ['../static/img/about_me/about_me_1_sm.jpg',
'../static/img/about_me/about_me_1_md.jpg',
'../static/img/about_me/about_me_1_lg.jpg',
'../static/img/about_me/about_me_1_xl.jpg',
'../static/img/about_me/about_me_1_xxl.jpg'],
'images': ['img/about_me/about_me_1_sm.jpg',
'img/about_me/about_me_1_md.jpg',
'img/about_me/about_me_1_lg.jpg',
'img/about_me/about_me_1_xl.jpg',
'img/about_me/about_me_1_xxl.jpg'],
'content': '''Before I provided animal caretaking services,
I focused my time on computers. I attended AACC
@ -15,11 +17,11 @@ content = {
I designed and coded this website!'''
},
'section 2': {
'images': ['../static/img/about_me/about_me_2_sm.jpg',
'../static/img/about_me/about_me_2_md.jpg',
'../static/img/about_me/about_me_2_lg.jpg',
'../static/img/about_me/about_me_2_xl.jpg',
'../static/img/about_me/about_me_2_xxl.jpg'],
'images': ['img/about_me/about_me_2_sm.jpg',
'img/about_me/about_me_2_md.jpg',
'img/about_me/about_me_2_lg.jpg',
'img/about_me/about_me_2_xl.jpg',
'img/about_me/about_me_2_xxl.jpg'],
'content': '''For the past 5 years, my interest in plants and
horticulture have expanded exponentially. As a kid,
my mother always had plants around our home. I
@ -29,11 +31,11 @@ content = {
because they're so easy to grow.'''
},
'section 3': {
'images': ['../static/img/about_me/about_me_3_sm.jpg',
'../static/img/about_me/about_me_3_md.jpg',
'../static/img/about_me/about_me_3_lg.jpg',
'../static/img/about_me/about_me_3_xl.jpg',
'../static/img/about_me/about_me_3_xxl.jpg'],
'images': ['img/about_me/about_me_3_sm.jpg',
'img/about_me/about_me_3_md.jpg',
'img/about_me/about_me_3_lg.jpg',
'img/about_me/about_me_3_xl.jpg',
'img/about_me/about_me_3_xxl.jpg'],
'content': '''My passion for animals and plants are what I
spend most my time on currently. I love providing
quality animal care.'''

View File

@ -5,11 +5,11 @@ content = {
{
'title': 'Walking',
'images': [
'../static/img/services/dog_walking_card_sm.png',
'../static/img/services/dog_walking_card_md.png',
'../static/img/services/dog_walking_card_lg.png',
'../static/img/services/dog_walking_card_xl.png',
'../static/img/services/dog_walking_card_xxl.png'],
'img/services/dog_walking_card_sm.png',
'img/services/dog_walking_card_md.png',
'img/services/dog_walking_card_lg.png',
'img/services/dog_walking_card_xl.png',
'img/services/dog_walking_card_xxl.png'],
'price': '$20/visit',
'included': [
'30 minute walk.',
@ -18,11 +18,11 @@ content = {
{
'title': 'Drop-in',
'images': [
'../static/img/services/drop_in_card_sm.png',
'../static/img/services/drop_in_card_md.png',
'../static/img/services/drop_in_card_lg.png',
'../static/img/services/drop_in_card_xl.png',
'../static/img/services/drop_in_card_xxl.png'],
'img/services/drop_in_card_sm.png',
'img/services/drop_in_card_md.png',
'img/services/drop_in_card_lg.png',
'img/services/drop_in_card_xl.png',
'img/services/drop_in_card_xxl.png'],
'price': '$20/visit',
'included': [
'30 minute in home visit.',
@ -31,11 +31,11 @@ content = {
{
'title': 'House sitting',
'images': [
'../static/img/services/house_sitting_card_sm.png',
'../static/img/services/house_sitting_card_md.png',
'../static/img/services/house_sitting_card_lg.png',
'../static/img/services/house_sitting_card_xl.png',
'../static/img/services/house_sitting_card_xxl.png'],
'img/services/house_sitting_card_sm.png',
'img/services/house_sitting_card_md.png',
'img/services/house_sitting_card_lg.png',
'img/services/house_sitting_card_xl.png',
'img/services/house_sitting_card_xxl.png'],
'price': '$38/visit',
'included': [
'Animal care.',

View File

@ -5,7 +5,7 @@
{% block content %}
<div class="row text-center mb-2">
<h1 class="text-primary display-1">
Frequently asked questions
{{ page.get_title() }}
</h1>
</div>

View File

@ -21,15 +21,16 @@
<picture>
{% for img in page.get_content()[row]['images'] %}
{% if not loop.last %}
<source srcset="{{ img }}"
<source srcset="{{ url_for('static', filename=img) }}"
media="(max-width: {{ config.IMG_BREAKPOINTS[loop.index] }})" />
{% else %}
<source srcset="{{ img }}"
<source srcset="{{ url_for('static', filename=img) }}"
media="(min-width: {{ config.IMG_BREAKPOINTS[loop.index] }})" />
{% endif %}
{% endfor %}
<img class="img-fluid" src="{{ page.get_content()[row]['images'][1] }}">
<img class="img-fluid"
src="{{ url_for('static', filename=page.get_content()[row]['images'][1]) }}">
</picture>
</div>
</div>

View File

@ -25,16 +25,16 @@
<picture>
{% for img in service['images'] %}
{% if not loop.last %}
<source srcset="{{ img }}"
<source srcset="{{ url_for('static', filename=img) }}"
media="(max-width: {{ config.IMG_BREAKPOINTS[loop.index] }})" />
{% else %}
<source srcset="{{ img }}"
<source srcset="{{ url_for('static', filename=img) }}"
media="(min-width: {{ config.IMG_BREAKPOINTS[loop.index] }})" />
{% endif %}
{% endfor %}
<img class="img-fluid card-img-top"
src="{{ service['images'][1] }}">
src="{{ url_for('static', filename=service['images'][1]) }}">
</picture>
<div class="card-body">
<h1 class="card-title text-center text-primary">{{ service['title'] }}</h1>