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

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen
 
(16 tussenliggende versies door dezelfde gebruiker niet weergegeven)
Regel 10: Regel 10:
 
=== Bestandsnaam ===
 
=== 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!
+
Zie [[SEO#Afbeeldingen - Bestandsnaam | SEO » Afbeeldingen - Bestandsnaam]]
  
=== Attachment Title ===
+
=== 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.
 
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.
 +
 +
=== 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.
  
 
=== Alt text ===
 
=== 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.
+
Zie [[SEO#Afbeeldingen - Alt-text | SEO » Afbeeldingen - Alt-tekst]]
  
 
=== Description ===
 
=== 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.
 
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.
 
  
 
== Bestandsnaam aanpassen? ==
 
== Bestandsnaam aanpassen? ==
Regel 37: Regel 37:
 
Dat kun je dus het beste vantevoren doen.
 
Dat kun je dus het beste vantevoren doen.
  
== Voorbeeld - Import zonder attributen ==
+
== Voorbeelden ==
 +
 
 +
=== Import zonder attributen ===
  
 
Script:
 
Script:
Regel 62: Regel 64:
 
Als ik het commando herhaal, wordt de afbeelding opnieuw geïmporteerd, maar met een ander ID. Je krijgt dus meerdere instanties vanhetzelfde object.
 
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 ==
+
=== Import met attributen ===
  
 
Script:
 
Script:
Regel 89: Regel 91:
 
Success: Imported 1 of 1 images.
 
Success: Imported 1 of 1 images.
 
</pre>
 
</pre>
 +
 +
=== Metadata met whitespace ===
 +
 +
Dit commando is gegenereerd in een rekenblad. Vandaar dat opmaak niet optimaal is. Het werkt prima:
 +
 +
<pre>
 +
wp media import /home/strompf/RT.ww/Productafbeeldingen/080-Afbeeldingen_voor_alle_talen/Widget-wiel-40x50x10-Smurf-wheel-rad.jpg --title="Widget-wiel met afmetingen 40x50x10 (mm) voor Smurf-systemen" --caption="Widget-wiel met afmetingen 40x50x10 (mm) voor Smurf-systemen" --alt="Widget-wiel 40x50x10 met SKU wheel_40x050x10 te koop op example.com.com" --desc="Widget-wiel voor Smurf-systemen. Afmetingen:
 +
 +
<ul>
 +
<li> Dim1: 40mm – 1.5748 Inch
 +
<li> Dim2: 50mm – 1.9685 Inch
 +
<li> Dim3: 10mm – 0.3937 Inch
 +
</ul>
 +
"
 +
</pre>
 +
 +
=== Inclusief auteur ===
 +
 +
Merk op dat de twee-voorlaatste " op de volgende regel is beland. Sois.
 +
<pre>
 +
wp media import /home/strompf/RT.ww/Productafbeeldingen/080-Afbeeldingen_voor_alle_talen/Widget-wiel-40x50x10-Smurf-wheel-rad.jpg --title="Widget-wiel met afmetingen 40x50x10 (mm) voor Smurf-systemen" --caption="Widget-wiel met afmetingen 40x50x10 (mm) voor Smurf-systemen" --alt="Widget-wiel 40x50x10 met SKU wheel_40x050x10 te koop op example.com.com" --desc="Widget-wiel voor Smurf-systemen. Afmetingen:
 +
 +
<ul>
 +
<li> Dim1: 40mm – 1.5748 Inch
 +
<li> Dim2: 50mm – 1.9685 Inch
 +
<li> Dim3: 10mm – 0.3937 Inch
 +
</ul>
 +
" --user="Jeroen Strompf"
 +
</pre>
 +
 +
== Zie ook ==
 +
 +
* [[Wp media (WP-CLI) | wp media]]
  
 
== Bronnen ==
 
== Bronnen ==
Regel 94: Regel 129:
 
* https://www.wpbeginner.com/wp-tutorials/image-meta-data-101-title-caption-alt-text-and-description
 
* https://www.wpbeginner.com/wp-tutorials/image-meta-data-101-title-caption-alt-text-and-description
 
* https://developer.wordpress.org/cli/commands/media/import/
 
* https://developer.wordpress.org/cli/commands/media/import/
 +
* https://saradoesseo.com/seo-basics/what-should-i-name-images-for-seo/

Huidige versie van 22 jun 2022 om 20:26

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

Zie SEO » Afbeeldingen - Bestandsnaam

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.

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.

Alt text

Zie SEO » Afbeeldingen - Alt-tekst

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.

Bestandsnaam aanpassen?

Standaard lijk je niet de bestandsnaam te kunnen aanpassen:

Dat kun je dus het beste vantevoren doen.

Voorbeelden

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.

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.

Metadata met whitespace

Dit commando is gegenereerd in een rekenblad. Vandaar dat opmaak niet optimaal is. Het werkt prima:

wp media import /home/strompf/RT.ww/Productafbeeldingen/080-Afbeeldingen_voor_alle_talen/Widget-wiel-40x50x10-Smurf-wheel-rad.jpg --title="Widget-wiel met afmetingen 40x50x10 (mm) voor Smurf-systemen" --caption="Widget-wiel met afmetingen 40x50x10 (mm) voor Smurf-systemen" --alt="Widget-wiel 40x50x10 met SKU wheel_40x050x10 te koop op example.com.com" --desc="Widget-wiel voor Smurf-systemen. Afmetingen:

<ul>
<li> Dim1: 40mm – 1.5748 Inch
<li> Dim2: 50mm – 1.9685 Inch
<li> Dim3: 10mm – 0.3937 Inch
</ul>
"

Inclusief auteur

Merk op dat de twee-voorlaatste " op de volgende regel is beland. Sois.

wp media import /home/strompf/RT.ww/Productafbeeldingen/080-Afbeeldingen_voor_alle_talen/Widget-wiel-40x50x10-Smurf-wheel-rad.jpg --title="Widget-wiel met afmetingen 40x50x10 (mm) voor Smurf-systemen" --caption="Widget-wiel met afmetingen 40x50x10 (mm) voor Smurf-systemen" --alt="Widget-wiel 40x50x10 met SKU wheel_40x050x10 te koop op example.com.com" --desc="Widget-wiel voor Smurf-systemen. Afmetingen:

<ul>
<li> Dim1: 40mm – 1.5748 Inch
<li> Dim2: 50mm – 1.9685 Inch
<li> Dim3: 10mm – 0.3937 Inch
</ul>
" --user="Jeroen Strompf"

Zie ook

Bronnen