corcel / acf

Advanced Custom Fields (ACF) plugin for Corcel
127 stars 100 forks source link

Allow to fetch custom meta fields for uploaded images. #22

Open Nube2021 opened 7 years ago

Nube2021 commented 7 years ago

Some Wordpress plugins allow the user in the backend to add some extra meta information to an image. For instance, the plugin „WP Gallery Custom Links“ allows to add a custom url, a css class and other information to an image. This commit adds a function to the Image Field class with which it is possible to fetch these custom meta fields. The function is called „fetchCustomMetaValues“ and receives as input a comma separated list or an array with the meta keys names that should be fetched.

Testing was included with the function „testImageCustomMetadataValues“ in ContentFieldsTest.php. The database was updated and includes now images with some extra meta fields. Here are the results of the tests:

$ ./vendor/bin/phpunit --filter {ContentFieldsTest::testImageCustomMetadataValues} PHPUnit 4.2.2 by Sebastian Bergmann.

Configuration read from ……/phpunit.xml

.

Time: 167 ms, Memory: 6.00MB

OK (1 test, 6 assertions)