Browse Source

display uploaded pokemon image in view

master
art.dambrine 4 years ago
parent
commit
b5a10958dd
  1. 1
      src/Controller/PokemonController.php
  2. 4
      templates/pokemon/index.html.twig
  3. 4
      templates/pokemon/show.html.twig

1
src/Controller/PokemonController.php

@ -48,7 +48,6 @@ class PokemonController extends AbstractController
15 /*Items per page*/
);
return $this->render('pokemon/index.html.twig', [
'pokemon' => $pokemons,
]);

4
templates/pokemon/index.html.twig

@ -52,8 +52,8 @@
<tbody>
{% for pokemon in pokemon %}
<tr>
<td scope="row">{{ pokemon.numero }}</td>
<td scope="row">{{ pokemon.nom }}</td>
<td scope="row">{{ pokemon.numero }}.</td>
<td scope="row">{{ pokemon.nom }} {% if pokemon.imageName %} <img style="margin-left: 5px;" src={{ asset('/images/pokemons/' ~ pokemon.imageName)}} alt="pokemon-img" height="30px"> {% endif %}</td>
<td scope="row">{{ pokemon.type1.name }}</td>
<td scope="row">{% if pokemon.type2 %} {{ pokemon.type2.name }} {% endif %}</td>
<td scope="row">{{ pokemon.generation.name }}</td>

4
templates/pokemon/show.html.twig

@ -5,8 +5,8 @@
{% block body %}
<h1>Pokemon</h1>
{% if imagePath %}
<img src={{ imagePath }} alt="pokemon-img" height="100px">
{% if pokemon.imageName %}
<img src={{ asset('/images/pokemons/' ~ pokemon.imageName)}} alt="pokemon-img" height="100px">
{% endif %}
<table class="table">

Loading…
Cancel
Save