Wp media import (WP-CLI)
Versie door Jeroen Strompf (overleg | bijdragen) op 4 apr 2019 om 10:04 (Nieuwe pagina aangemaakt met 'thumb|Import inclusief attributen file:20190404-0945.png|thumb|Wat je kunt terugvinden in de broncode (de afbeelding is niet klikbaar):...')
Met wp media import kun je afbeeldingen importeren inclusief attributen, en allerlei bijbehorende truuks uithalen. Wat je niet lijkt te kunnen doen: De bestandsnaam aanpassen (dus dat de bestandsnaam na import anders is dan daarvoor).
Voorbeeld - Import zonder attributen
Script:
#!/bin/bash # Import an image without attributes #################################### # cd /var/www/rt_tmp.dvb wp media import /home/strompf/RT.ww/060-Metadata-import/EscobillasIndustriales.jpg
Shell:
./importtest Imported file '/home/strompf/RT.ww/060-Metadata-import/EscobillasIndustriales.jpg' as attachment ID 1306. Success: Imported 1 of 1 items.
Als ik het commando herhaal, wordt de afbeelding opnieuw geïmporteerd, maar met een ander ID. Je krijgt dus meerdere instanties vanhetzelfde object.
Voorbeeld - Import met attributen
Script:
#!/bin/bash # Image including attributes ############################ # cd /var/www/rt_tmp.dvb wp media import \ /home/strompf/RT.ww/060-Metadata-import/windmolen_338x225.jpg \ --title="Various carbon brushes, with one resembling a windmill" \ --caption="We have lots of these, and w're creative, too!" \ --alt="Create image of a bunch of carbon brushes" \ --desc="Various carbon brushes, to have an impression of our assortment" \
Shell:
./importtest Imported file '/home/strompf/RT.ww/060-Metadata-import/windmolen_338x225.jpg' as attachment ID 1307. Success: Imported 1 of 1 images.