Wp media import (WP-CLI): verschil tussen versies

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen
Regel 5: Regel 5:
  
 
== Attributen ==
 
== Attributen ==
 
Zie [[Wp media import (WP-CLI)]] voor een overzicht van de beschikbare velden.
 
  
 
Deels overgenomen van [https://www.wpbeginner.com/wp-tutorials/image-meta-data-101-title-caption-alt-text-and-description WPBeginner.com]:
 
Deels overgenomen van [https://www.wpbeginner.com/wp-tutorials/image-meta-data-101-title-caption-alt-text-and-description WPBeginner.com]:

Versie van 4 apr 2019 10:08

Import inclusief attributen
Wat je kunt terugvinden in de broncode (de afbeelding is niet klikbaar): Originele bestandsnaam en Alt-text

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).

Attributen

Deels overgenomen van WPBeginner.com:

Bestandsnaam

Vermoedelijk het belangrijkste attribuut: De bestandsnaam van een afbeelding. Ik denk dat dat de primaire bron is voor Google om een afbeelding te classificeren. Helaas kun je met wp media import niet dynamisch de bestandsnaam aanpassen. Jammer!

Attachment Title

The title field in the attachment details allow you to provide a title to your image. This title is used internally by WordPress to sort images in the media library.

Alt text

The image alt text, alt text, alt or alternate text is a required field by the HTML standards specifications. It is displayed when a user’s browser is unable to locate an image. Search engines like Google use alt tag as a ranking factor in their image search results. See our guide on what’s the difference between image alt text vs image title in WordPress.

Description

This text can be displayed on the attachment page for your image. You can enter as much information as you want in the description field. Like the story behind a photograph, how you took the picture, or anything else that you want to share can go here. You can even add links in the description field.

Caption

This is the text that you want to display with your image. Depending on your theme, it will be displayed inside image border or outside the image. See our guide on how to add caption to images in WordPress.

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.

Bronnen

https://developer.wordpress.org/cli/commands/media/import/