Created
August 8, 2019 02:06
-
-
Save parzibyte/442ce682d5809676342ac6717adfceb8 to your computer and use it in GitHub Desktop.
Convertir imagen normal a imagen AMP con PHP - https://parzibyte.me/blog/2018/08/29/expresion-regular-para-imagenes-amp/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$contenido = '<p>Soy un párrafo</p><img class="img-fluid" alt="Imagen" src="https://avatars0.githubusercontent.com/u/9124824?v=4">'; | |
$contenidoAMP = preg_replace('/<img.*?src="([^"]*)".*?>/i', '<amp-img width="10" height="5" layout="responsive" src="$1"></amp-img>', $contenido); | |
echo $contenidoAMP; | |
#Imprime: | |
/* | |
<p>Soy un párrafo</p><amp-img width="10" height="5" layout="responsive" src="https://avatars0.githubusercontent.com/u/9124824?v=4"></amp-img> | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment