Skip to content

Commit

Permalink
Add check for image files (organizer, speaker and sponsor) - Fix devo…
Browse files Browse the repository at this point in the history
  • Loading branch information
somatorio committed Oct 25, 2018
1 parent db85ba7 commit 247c368
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
9 changes: 8 additions & 1 deletion layouts/partials/sponsors.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ <h4 class="sponsor-cta">{{ $level.label }} Sponsors</h4>
{{- end -}}

<div class = "col-lg-1 col-md-2 col-4">
<a href = "{{ $.Scratch.Get "SponsorURL" }}"><img src = "/img/sponsors/{{ .id }}.png" alt = "{{ $s.name }}" title = "{{ $s.name }}" class="img-fluid"></a>
<a href = "{{ $.Scratch.Get "SponsorURL" }}">
{{ $imagefile := printf "static/img/sponsors/%s.png" .id }}
{{ if fileExists $imagefile }}
<img src = "/img/sponsors/{{ .id }}.png" alt = "{{ $s.name }}" title = "{{ $s.name }}" class="img-fluid">
{{ else }}
{{ errorf "%s not found" $imagefile }}
{{ end }}
</a>
</div>
{{- end -}}
{{- end -}}
Expand Down
5 changes: 5 additions & 0 deletions layouts/shortcodes/list_organizers.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ <h4>Organizer</h4>
{{ end }}
</div>
{{- if .image -}}
{{ $imagefile := printf "static/events/%s/organizers/%s" $e.name .image }}
{{ if (fileExists $imagefile) -}}
<img class="card-img-top organizer-image" src="{{ (printf "events/%s/organizers/%s" $e.name .image) | absURL }}" alt="{{ .name }}">
{{- else }}
{{ errorf "%s not found" $imagefile }}
{{- end }}
{{- end -}}
<div class = "card-block">
{{- if .employer -}}
Expand Down
5 changes: 5 additions & 0 deletions layouts/speaker/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ <h3>{{ .Title }} at {{ $e.city }} {{$e.year}}</h3>
<div class = "col-md-3 offset-md-1">
{{- if isset .Params "image" -}}
{{- if ne .Params.image "" -}}
{{ $imagefile := printf "static/events/%s/speakers/%s" $e.name .Params.image }}
{{ if fileExists $imagefile }}
<img src = "{{ (printf "events/%s/speakers/%s" $e.name .Params.image) |absURL }}" class="img-fluid" alt="{{ .Title }}"/><br />
{{ else }}
{{ errorf "%s not found" $imagefile }}
{{ end }}
{{- end -}}
{{- else -}}
<img src = {{ "img/speaker-default.jpg" | absURL }} class="img-fluid" alt="{{ .Title }}"/><br />
Expand Down
5 changes: 5 additions & 0 deletions layouts/speakers/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
<a href = "{{ .Permalink | absURL }}">
{{- if isset .Params "image" -}}
{{- if ne .Params.image "" -}}
{{ $imagefile := printf "static/events/%s/speakers/%s" $e.name .Params.image }}
{{ if fileExists $imagefile }}
<img src = "{{ (printf "events/%s/speakers/%s" $e.name .Params.image) | absURL}}" class="speakers-page img-fluid" alt="{{ .Title }}"/><br />
{{ else }}
{{ errorf "%s not found" $imagefile }}
{{ end }}
{{- end -}}
{{- else -}}
<img src = "{{"img/speaker-default.jpg" | absURL }}" class="speakers-page img-fluid" alt="{{ .Title }}"/><br />
Expand Down

0 comments on commit 247c368

Please sign in to comment.