-
-
Notifications
You must be signed in to change notification settings - Fork 25
DataDragonAPI: Usage example
Daniel Dolejška edited this page Jan 27, 2018
·
8 revisions
Let's show Orianna's loading screen image without skin and with Dark Star skin.
Source:
echo DataDragonAPI::getChampionLoading('Orianna');
echo DataDragonAPI::getChampionLoading('Orianna', 7);
Output:
<img src="http://ddragon.leagueoflegends.com/cdn/img/champion/loading/Orianna_0.jpg" class="dd-icon dd-loading" alt="Orianna">
<img src="http://ddragon.leagueoflegends.com/cdn/img/champion/loading/Orianna_7.jpg" class="dd-icon dd-loading" alt="Orianna">
Render:
Now, let's take a look at some spells:
Source:
DataDragonAPI::iniByCdn();
echo DataDragonAPI::getSpellIcon('SummonerFlash');
echo DataDragonAPI::getSpellIcon('OriannaDetonateCommand');
echo DataDragonAPI::getSpellIcon('EzrealTrueshotBarrage');
Output:
<img src="http://ddragon.leagueoflegends.com/cdn/8.2.1/img/spell/SummonerFlash.png" class="dd-icon dd-spell" alt="SummonerFlash">
<img src="http://ddragon.leagueoflegends.com/cdn/8.2.1/img/spell/OrianaDetonateCommand.png" class="dd-icon dd-spell" alt="OrianaDetonateCommand">
<img src="http://ddragon.leagueoflegends.com/cdn/8.2.1/img/spell/EzrealTrueshotBarrage.png" class="dd-icon dd-spell" alt="EzrealTrueshotBarrage">
Render:
...a bit of nostalgia?
Source:
DataDragonAPI::iniByVersion('0.151.2');
echo DataDragonAPI::getItemIcon(3132);
echo DataDragonAPI::getItemIcon(3126);
echo DataDragonAPI::getItemIcon(3138);
Output:
<img src="http://ddragon.leagueoflegends.com/cdn/0.151.2/img/item/3132.png" class="dd-icon dd-item" alt="3132">
<img src="http://ddragon.leagueoflegends.com/cdn/0.151.2/img/item/3126.png" class="dd-icon dd-item" alt="3126">
<img src="http://ddragon.leagueoflegends.com/cdn/0.151.2/img/item/3138.png" class="dd-icon dd-item" alt="3138">
Render:
By specifying DataDragonAPI::SET_CUSTOM_IMG_ATTRS
, we can add attributes to all generated <img>
tags.
By specifying $attributes
as well (specified when calling the function), we can override values set in DataDragonAPI::SET_CUSTOM_IMG_ATTRS
. Only class
attribute is concatenated and not overridden.
Source:
DataDragonAPI::iniByCdn([
DataDragonAPI::SET_CUSTOM_IMG_ATTRS => [
'class' => 'class1 class2',
'data-toggle' => 'tooltip',
'title' => 'Default title',
]
]);
// no extra attributes
echo DataDragonAPI::getSpellIcon('SummonerFlash');
// one more class
echo DataDragonAPI::getSpellIcon('SummonerFlash', [
'class' => 'class3',
]);
// overriding preset attributes
echo DataDragonAPI::getSpellIcon('SummonerFlash', [
'alt' => 'Spell Flash',
'title' => 'Flash',
]);
Output:
<img class="dd-icon dd-spell class1 class2" alt="SummonerFlash" data-toggle="tooltip" title="Default title" src="http://ddragon.leagueoflegends.com/cdn/8.2.1/img/spell/SummonerFlash.png">
<img class="dd-icon dd-spell class1 class2 class3" alt="SummonerFlash" data-toggle="tooltip" title="Default title" src="http://ddragon.leagueoflegends.com/cdn/8.2.1/img/spell/SummonerFlash.png">
<img class="dd-icon dd-spell class1 class2" alt="Spell Flash" data-toggle="tooltip" title="Flash" src="http://ddragon.leagueoflegends.com/cdn/8.2.1/img/spell/SummonerFlash.png">
DataDragonAPI
can use result objects from RiotAPI
to easily render some assets.
Source:
$api = new RiotAPI([...]);
DataDragonAPI::iniByApi($api); // you can init by anything else
$orianna = $api->getStaticChampion(61, null, null, 'all');
echo DataDragonAPI::getChampionSplashO($orianna);
foreach($orianna->spells as $spell)
echo DataDragonAPI::getChampionSpellIconO($spell);
Output:
<img src="http://ddragon.leagueoflegends.com/cdn/img/champion/splash/Orianna_0.jpg" class="dd-icon dd-splash" alt="Orianna">
<img src="http://ddragon.leagueoflegends.com/cdn/8.2.1/img/spell/OrianaIzunaCommand.png" class="dd-icon dd-spell" alt="OrianaIzunaCommand">
<img src="http://ddragon.leagueoflegends.com/cdn/8.2.1/img/spell/OrianaDissonanceCommand.png" class="dd-icon dd-spell" alt="OrianaDissonanceCommand">
<img src="http://ddragon.leagueoflegends.com/cdn/8.2.1/img/spell/OrianaRedactCommand.png" class="dd-icon dd-spell" alt="OrianaRedactCommand">
<img src="http://ddragon.leagueoflegends.com/cdn/8.2.1/img/spell/OrianaDetonateCommand.png" class="dd-icon dd-spell" alt="OrianaDetonateCommand">