$api = json_decode($this->api, true);
}
$seo = $this->getTranslations('seo');
+ $images = $this->getTranslations('images');
$hasChanged = false;
}
}
+ foreach ($images[$mainLocale] as $id => $alt) {
+ if ($api['images'][$id] !== $alt) {
+ $api['images'][$id] = $alt;
+ Webflow::saveImageAlt($id, $alt);
+ }
+ }
+
if ($hasChanged) {
$this->api = json_encode($api);
$this->saveQuietly();
}
$this->setTranslations('texts', $translations);
+ $data = Json::decode($this->images, Json::TYPE_ARRAY);
+ foreach ($this->api['images'] as $image) {
+ $data[$mainLocale][$image['id']] = str_starts_with($image['alt'], '__wf_') ? '' : $image['alt'];
+ }
+ foreach ($locales as $locale) {
+ if ($locale === $mainLocale) {
+ continue;
+ }
+ if (!isset($data[$locale])) {
+ $data[$locale] = [];
+ }
+ foreach ($data[$mainLocale] as $id => $alt) {
+ if (!isset($data[$locale][$id]) || !$data[$locale][$id]) {
+ $data[$locale][$id] = $alt ? $translateAPI->translate($alt, $locale, $mainLocale) : '';
+ }
+ }
+ }
+ $this->setTranslations('images', $data);
+
$this->saveQuietly();
} catch (LockTimeoutException $e) {
return self::paginatedRequest('sites/' . self::getSiteId($shortname) . '/assets', 'assets');
}
+ public static function saveImageAlt($id, $alt)
+ {
+
+ }
+
public static function getEditableData($shortname)
{
$key = self::getToken() . '_' . $shortname;
}
$res['texts'][$node['text']['text']]['occurences']++;
} else if ($node['type'] === 'image') {
+
if (!isset($node['image']['assetId'])) {
continue;
}
if (isset($res['images'][$assetId])) {
continue;
}
- $res['images'][$assetId] = ['id' => $assetId, 'alt' => $node['image']['alt'], 'url' => $data['assets'][$assetId]['hostedUrl']];
+ $res['images'][$pageID . '_' . $assetId] = ['page' => $pageID, 'id' => $assetId, 'alt' => $node['image']['alt'], 'url' => $data['assets'][$assetId]['hostedUrl']];
}
}
}
+@php
+ $value=old(square_brackets_to_dots($field['name'])) ?? $field['value'] ?? $field['default'] ?? '[]';
+ $translations=\Cubist\Util\Json::decode($value,\Cubist\Util\Json::TYPE_ARRAY)??[];
+ $images=\Cubist\Util\Json::decode($crud->entry->api,\Cubist\Util\Json::TYPE_ARRAY)['images'];
+@endphp
+
+@include('crud::fields.inc.wrapper_start')
+<label>{!! $field['label'] !!}</label>
+@include('crud::fields.inc.translatable_icon')
+
+<table style="width: 100%">
+ <tr>
+ <th>Aperçu de l'image</th>
+ <th>Texte alternatif</th>
+ </tr>
+ @foreach($images as $id=>$image)
+ @php
+ $e=explode('/',$image['url']);
+ $ee=array_pop($e);
+ $e=explode('_',$ee,2);
+ $short=$e[1];
+ @endphp
+ <tr>
+ <td style="padding: 5px;width: 60%;">
+ <div
+ style="padding:5px;background-color:#efefef;width: 100%;height: 600px;background-image:url({!! $image['url'] !!});background-size: cover;background-position: 50% 50%"></div>
+ </td>
+ <td style="vertical-align: top;padding: 5px;width: 40%">
+ # {{$id}}<br>
+ <a href="{!! $image['url'] !!}" style="word-break: break-all">{!! $short !!}</a>
+ <textarea style="width: 100%" rows="3"
+ name="{{ $field['name'] }}[{{$image['id']}}]" @include('crud::fields.inc.attributes')>{{$translations[$image['id']]}}</textarea>
+ </td>
+ </tr>
+ @endforeach
+</table>
+{{-- HINT --}}
+
+@include('crud::fields.inc.wrapper_end')