Giter Site home page Giter Site logo

mundschenk-at / media-credit Goto Github PK

View Code? Open in Web Editor NEW
2.0 5.0 1.0 4.05 MB

Adds a "Credit" field when uploading media to posts and displays it under the images on your blog to properly credit the artist.

License: GNU General Public License v2.0

PHP 85.49% JavaScript 14.02% SCSS 0.49%
shortcode wordpress tinymce artists copyright photos

media-credit's Introduction

Media Credit

Build Status Latest Stable Version Quality Gate Status Coverage License

Adds a "Credit" field when uploading media to posts and displays it under the images on your blog to properly credit the artist.

Requirements

  • PHP 7.4.0 or above
  • WordPress 5.9 or above

media-credit's People

Contributors

mundschenk-at avatar sbressler avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

phillipian

media-credit's Issues

Updating credit in Visual Editor does not work any more

  1. Access edit page of any post (ex. meusite.com/wp-admin/post.php?post=2296&action=edit)
  2. Select an image already inserted on post content and click at pencil icon to edit image
  3. Put some text (or modify an existent) on "Credit" field and click "Update"
  4. The new credit text didn't appear on image post content
  5. Save post and view it... Nothing happens. The credit text wasn't update.

From https://wordpress.org/support/topic/media-credit-doesnt-display-if-no-caption-present?replies=16

Add unit tests

Currently, there are no unit tests at all. This has to change soon.

Media Credit shortcode fails when editing embedded image properties

From the WordPress support forums (on WordPress 5.5.1):

When I insert an image into my page using the Add Media dialog, and then manipulate its properties from the context menu which results from clicking the image, the resulting markup isn’t a shortcode, but what appears to be temporary markup, ie:

<div class=”mceMediaCreditOuterTemp alignnone” style=”width: 721px”><span class=”mceMediaCreditTemp mceNonEditable” data-media-credit-text=”credit text” data-media-credit-align=”alignnone” data-media-credit-link=”credit.com”>credit text</span>…</div>

When I click “Add Media” and add the Credit & Credit URL values in the image properties dialog in the sidebar, then the resulting shortcode does get generated properly, ie:

[media-credit name=”credit text” link=”credit.com” align=”alignnone” width=”638″][/media-credit]

Steps which produce the error:

In Visual Mode, click “Add Media” button to invoke media overlay

  1. Choose an image
  2. Click “Insert into Post”
  3. In Visual Mode, click the image, to invoke the context menu
  4. Click the pencil icon to edit image properties
  5. Add a “Credit” value
  6. Add a “Credit URL” value
  7. Click “Update”

The resulting markup is html, instead of a shortcode.

Steps which don’t produce the error:

  1. In Visual Mode, click “Add Media” button to invoke media overlay
  2. Choose an image
  3. Add a “Credit” value in the Attachment Details sidebar
  4. Add a “Credit URL” value in the Attachment Details sidebar
  5. Click “Insert into Post”

The resulting markup is a shortcode.

Add "no-follow" attribute

Add a way to mark external links as "no-follow":

  • for attachments: post_meta
  • for specific credits: shortcode attribute

Can’t upload media using Add Media within Add New Post / Edit Post

Reported via the WordPress.org support forums:

Since version 4.0.0, when the plugin is active, I cannot upload any Media using the Add Media button within Edit Post (post creation or post edit). I get the following error in the Google Chrome console:

Uncaught TypeError: Cannot read property ‘placeholder’ of undefined
at eval (eval at s.template (underscore.min.js:1), :7:26)
at i (underscore.min.js:1)
at wp-util.min.js:1
at N.d.template (media-credit-attachment-details.min.js:3)
at N.d.render (media-views.min.js:2)
at N.d.render (media-credit-attachment-details.min.js:3)
at wp.Backbone.Subviews. (wp-backbone.min.js:1)
at underscore.min.js:1
at Function.s.each.s.forEach (underscore.min.js:1)
at wp.Backbone.Subviews._attach (wp-backbone.min.js:1)

Allow to change / set the default media credit

Hi there,

I was wondering if it is possible to set a default media credit string or to overwrite the existing logic via a filter or such since the default always reads "User SEPARATOR Organization" and we would like to be able to just have it always read X by default and then we can set it differently if need be...

Any chance of hooking into that?

Thanks!

Use placeholder instead of default text when `do not display default credit` is set

The 'add_media_credit' function that builds the input fields for the media editor automatically adds the media uploaders name to the credit line. This is problematic when you do not want to provide credit to a specific media asset, but do want to make an adjustment to something like Yoast SEO values or Alt/Description tags. You have to manually clear the credit field out since it is pre-populated.

I made the following update to add_media_credit on my end, which seems to make a bit more sense to me.

$credit = get_freeform_media_credit($post);
$credit_user = get_wpuser_media_credit($post);

$html = "<input id='attachments[$post->ID][media-credit]' class='media-credit-input' size='30' value='$credit' placeholder='$credit_user' name='attachments[$post->ID][media-credit]'  />";

Basically, I pull the freeform credit, and use that for the input value, and then use the wpuser as the placeholder. This shows the uploader in 'grey' (by default), and if the 'do not display default credit' option is unchecked, this is what will appear.

Enhancement request based on https://wordpress.org/support/topic/add_media_credit-doesnt-obey-include-default-credit

Proper handling of cases with no caption and no credit in visual editor

https://wordpress.org/support/topic/mcemediacreditoutertemp-divs-appearing:

But one of the editors is having an issue with images that don't have a media credit or caption. Placing the image on the page seems to work just fine. But going back and then editing the image results in the image (and sometimes the headline gets thrown in there too) being wrapped in this div code that messes with the layout:

<div class="mceMediaCreditOuterTemp alignright" style="width: 250px;"></div>

Improved Composer dependency handling

Use a "scoping" package to change dependency namespaces to prevent incorrect dependency versions (from other WordPress plugins) from being loaded.

Handle legacy shortcode "align" values

The value range for the align shortcode attribute has been changed. Instead of align="align left" the new syntax is align="left". The old attribute values should be silently upgraded, though.

Saving Media Credit settings throws an error

If I press save on the page: /wp-admin/options-media.php#media-credit, the following errors appear:

`
Notice: Array to string conversion in /home/abcde/public_html/wp-includes/formatting.php on line 1025

Notice: Array to string conversion in /home/abcde/public_html/wp-includes/formatting.php on line 1025
`

Wordpress 4.6
Media Credit 3.1.1

Add fields to REST API Media endpoint.

Hey,
thanks for this plugin!
it would be nice if this plugin get self registered to the REST API Media endpoint
eg: url.com/wp-json/wp/v2/media/anynumber
So we can deliver instantly the credits with the media.

For me i found this solution for theme/function.php

add_action('rest_api_init', 'tb_add_custom_rest_fields');
function tb_add_custom_rest_fields() {
    // schema
    $media_credits_schema = array(
        'description'   => 'Copyright of the media item',
        'type'          => 'string',
        'context'       => ['view']
    );

    // registering the field
    register_rest_field(
        'attachment',
        'media_credits',
        [
            'get_callback'      => 'get_media_credits',
            'update_callback'   => null,
            'schema'            => $media_credits_schema
        ]
    );
}

function get_media_credits($object, $field_name, $request) {
    //return 'this-is-a-test';
   	return array(
		'copyright' => get_media_credit(),  
		'copyright_url' => get_media_credit_url(), 
		'copyright_html' => get_media_credit_html(), 
	);
}

This will add fields like this

...
"media_credits":  {
  "copyright":"© test",
  "copyright_url": "http://www.google.de",
  "copyright_html": "<a href=\"http://www.google.de/\">© test</a>"
},
...

Thanks for the plugin and reading!
I hope you are able to add this feature in near future.
Because of all the headless CMS trends it would be nice.
regards
dnl

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.