Wp media import (WP-CLI): verschil tussen versies
(19 tussenliggende versies door dezelfde gebruiker niet weergegeven) | |||
Regel 10: | Regel 10: | ||
=== Bestandsnaam === | === Bestandsnaam === | ||
− | + | Zie [[SEO#Afbeeldingen - Bestandsnaam | 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. | 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 === | ||
− | + | Zie [[SEO#Afbeeldingen - Alt-text | SEO » Afbeeldingen - Alt-tekst]] | |
=== Description === | === Description === | ||
Regel 24: | Regel 28: | ||
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. | ||
− | == | + | == Bestandsnaam aanpassen? == |
+ | |||
+ | Standaard lijk je niet de bestandsnaam te kunnen aanpassen: | ||
+ | |||
+ | * https://www.google.nl/search?q=wp+media+upload+change+file+name | ||
+ | * https://stackoverflow.com/questions/3259696/rename-files-during-upload-within-wordpress-backend | ||
+ | |||
+ | Dat kun je dus het beste vantevoren doen. | ||
− | + | == Voorbeelden == | |
− | == | + | === Import zonder attributen === |
Script: | Script: | ||
Regel 53: | 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. | ||
− | == | + | === Import met attributen === |
Script: | Script: | ||
Regel 80: | 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 85: | 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
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:
- https://www.google.nl/search?q=wp+media+upload+change+file+name
- https://stackoverflow.com/questions/3259696/rename-files-during-upload-within-wordpress-backend
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"