Construye galer铆as de im谩genes con Hive Translator 馃嚜馃嚫 馃嚞馃嚙

Words
349
Reading
2 min
3y
Listen to this post
~2 min


gallery.png


ENGLISH VERSION


Hello dear HiveDevs friends, today I come to present you one of the last functions I have added to HiveTranslator.com. But first let me have a small pitch.

Hive Translator is a translator and text formatter for Hive, developed by me, from Cuba 馃嚚馃嚭 for the blockchain. It is an accessibility tool that allows users to build bilingual posts for communities that allow it. And by the way, overcome the language barrier.

The feature I present to you today has little to do with the main function of the app. But it has been quite demanded by the community. It is an option of format to add image galleries to our posts. For this, it simply uses some javascript running on Flask to concatenate the markdown codes of images with those of a table and build a gallery. Next I show you the code fragment of said function.

Hola queridos amigos de HiveDevs, hoy vengo a presentarles una de las 煤ltimas funciones que he agregado a HiveTranslator.com. Pero antes perm铆tanme un pequ帽o pitch.

Hive Translator es un traductor y maquetador de textos para Hive, desarrollado por m铆, desde Cuba 馃嚚馃嚭 para la blockchain. Se trata de una herramienta de accesibilidad que permite a los usuarios constru铆r posts bilingues para las comunidades que as铆 lo permitan. Y de paso, sortear la barrera ling眉铆stica.

El feature que les presento hoy no tiene mucho que ver con la funci贸n principal del app. Pero s铆 ha sido bastante demandada por la comunidiad. Se trata de una opci贸n de formato para agregar galer铆as de im谩genes a nuestros posts. Para ello, simplemente utiliza algo de javascript corriendo sobre Flask para concatenar los c贸digos markdown de im谩genes con los de una tabla y construir una galer铆a. A continuaci贸n les muestro el fragmento de c贸digo de dicha funci贸n.

function buildGallery() {
   var textarea = document.getElementById('input-text');
   var startPos = textarea.selectionStart;
   var selectedText = textarea.value.substring(startPos);
   var img1 = document.getElementById('image1');
   var img2 = document.getElementById('image2');
   var img3 = document.getElementById('image3');
   var dialogo = document.getElementById("gallery");
   var replacement;
                
   if (img3.value !== "") {
      replacement = '|' + img1.value + '|' + img2.value + '|' + img3.value + '|' + '\n' + '|-|-|-|' + '\n';
      } else {
            replacement = '|' + img1.value + '|' + img2.value + '|' + '\n' + '|-|-|' + '\n';
      }

      textarea.value = textarea.value.substring(0, startPos) + replacement + selectedText;
   dialogo.style.display = "none";
 }

Apoya este post

  • Rebloguea el post 馃攣
  • Comparte en las redes sociales #Web2 馃敆
  • Comenta para debatir y gana recompensas manuales 馃挰

Recursos empleados

RECURSO / RESOURCEFUENTE / SOURCE
Edici贸n / Edition:noakmilo@noakmilo
Texto / Text:noakmilo@noakmilo
Im谩genes / Pictures:Canva, noakmilo@noakmilo, Hive Translator, Google Analytics, OpenAI

鈻讹笍 3Speak